当我从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
答案 0 :(得分:2)
我在fs
包裹上遇到了同样的问题。
ERROR in dll reactBoilerplateDeps
Module not found: Error: Can't resolve 'fs' in '/Users/nico/_dev/crf'
@ dll reactBoilerplateDeps
为避免此错误,我忽略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',
},
};
我不知道是否是最好的解决方案,但对我来说工作正常。
注意强>
在:
我尝试rm -r node_modules && npm cache clean && npm install
,但错误仍然是
我在internals/config.js文件中的dllPlugin fs
数组中插入了exclude
依赖项,但错误仍然存在
<强>文档强>
webpack配置中的 node
键包括用于各种节点内容的polyfill或模拟