[英]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
: Modulestream
does not exist in the Haste module map捆绑失败:错误:无法从/Users/username/React Native/SampleApp/node_modules/browser-stdout/index.js
解析模块stream
:Haste 模块映射中不存在模块stream
It's giving error for this line :这行给出错误:
var WritableStream = require('stream').Writable
I tried installing 'stream' via npm我尝试通过 npm 安装“流”
npm install stream
Then other similar errors started showing up.然后其他类似的错误开始出现。
One option is to use the client package readable-stream .一种选择是使用客户端包readable-stream 。 If dependencies are requiring stream
, then i would suggest adding the following to your babel config as well.如果依赖项需要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',
},
},
],
],
};
只需使用 npm install stream 安装流并再次运行项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.