如何修复`npm install`错误与react-boilerplate?

当我从反应样板文件运行npm install ,我的第三方模块发出了一些错误,如下所示。 所有这些模块在其他节点项目中都能正常工作,而不是在反应模板中。 有谁知道如何解决这些问题?

 ERROR in ./~/nconf/lib/nconf.js Module not found: Error: Can't resolve 'fs' in '/Users/me/src/fullboar/probate-web/node_modules/nconf/lib' @ ./~/nconf/lib/nconf.js 8:9-22 ERROR in ./~/nconf/package.json Module parse failed: /Users/me/src/fullboar/probate-web/node_modules/nconf/package.json Unexpected token (2:9) You may need an appropriate loader to handle this file type. | { | "_args": [ | [ | { @ ./~/nconf/lib/nconf.js 21:16-42 ERROR in ./~/nconf/lib/nconf/common.js Module not found: Error: Can't resolve 'fs' in '/Users/me/src/fullboar/probate-web/node_modules/nconf/lib/nconf' @ ./~/nconf/lib/nconf/common.js 8:9-22 ERROR in ./~/sequelize/package.json Module parse failed: /Users/me/src/fullboar/probate-web/node_modules/sequelize/package.json Unexpected token (2:9) You may need an appropriate loader to handle this file type. | { | "_args": [ | [ | { @ ./~/sequelize/lib/sequelize.js 265:20-46 

我对fs包有同样的问题。

 ERROR in dll reactBoilerplateDeps Module not found: Error: Can't resolve 'fs' in '/Users/nico/_dev/crf' @ dll reactBoilerplateDeps 

为了避免这个错误,我忽略了浏览器构build的fs模块,像这样更新webpack.dll.babel.js文件:

  // ... plugins: [ new webpack.DllPlugin({ name: '[name]', path: join(outputPath, '[name].json') }), // eslint-disable-line no-new ], // mock fs node: { fs: 'empty', }, }; 

我不知道是否是最好的解决scheme,但对我来说工作正常。

注意

之前:

  • 我试图rm -r node_modules && npm cache clean && npm install但是错误依然存在

  • 我插入内部/ config.js文件中的dllPlugin exclude数组中的fs依赖项,但错误仍然存​​在

文档

webpackconfiguration中的node密钥包括多种填充或模拟各种节点的东西

Interesting Posts