Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve module `stream`

This error starting showing up all of a sudden.

Node : v10.16.3
React native : 0.60.5
react-native-cli: 2.0.1

bundling failed: Error: Unable to resolve module stream from /Users/username/React Native/SampleApp/node_modules/browser-stdout/index.js: Module stream does not exist in the Haste module map

It's giving error for this line :

var WritableStream = require('stream').Writable

I tried installing 'stream' via npm

npm install stream

Then other similar errors started showing up.

like image 338
Shahal Avatar asked Aug 25 '19 07:08

Shahal


1 Answers

One option is to use the client package readable-stream. If dependencies are requiring stream, then i would suggest adding the following to your babel config as well.

yarn add readable-stream

yarn add -D babel-plugin-rewrite-require

babel.config.js

module.exports = {
  // rest of config
  plugins: [
    // other plugins
    [
      'babel-plugin-rewrite-require',
      {
        aliases: {
          stream: 'readable-stream',
        },
      },
    ],
  ],
};
like image 102
Taylor Johnson Avatar answered Nov 17 '22 11:11

Taylor Johnson