无法解析模块`stream`

Sha*_*hal 7 npm react-native react-native-android

这个错误突然开始出现。

Node : v10.16.3
React native : 0.60.5
react-native-cli: 2.0.1
Run Code Online (Sandbox Code Playgroud)

捆绑失败:错误:无法stream/Users/username/React Native/SampleApp/node_modules/browser-stdout/index.js以下位置解析模块:模块stream在 Haste 模块映射中不存在

它给出了这一行的错误:

var WritableStream = require('stream').Writable
Run Code Online (Sandbox Code Playgroud)

我尝试通过 npm 安装“流”

npm install stream
Run Code Online (Sandbox Code Playgroud)

然后其他类似的错误开始出现。

Tay*_*son 5

一种选择是使用客户端包read-stream。如果需要依赖项stream,那么我建议将以下内容也添加到您的 babel 配置中。

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',
        },
      },
    ],
  ],
};
Run Code Online (Sandbox Code Playgroud)