javascript – 在Webpack中的/ node_modules / watchpack中获取“无法解析模块’aws-sdk’,’child_process’,’net’”
作者:互联网
我正在尝试构建我的prod webpack文件并获得5-10个“无法解析模块”的错误aws-sdk,child_process“.
所有这些错误都以相同的路径开始:“(webpack)/〜/ watchpack /〜/ chokidar /〜/ fsevents /”中的错误
例如:
ERROR in(webpack)/〜/ watchpack /〜/ chokidar /〜/ fsvents /〜/ node-pre-ygyp / lib / node-pre -gyp.js
找不到模块:错误:无法解析’文件’或’目录’../package
错误(webpack)/~/watchpack/~/chokidar/~/fsevents/~/node-pre-gyp/lib/info.js
找不到模块:错误:无法解析模块’aws-sdk’
ERROR in(webpack)/~/watchpack/~/chokidar/~/fsevents/~/node-pre-gyp/lib/publish.js
找不到模块:错误:无法解析模块’aws-sdk’
错误在(webpack)/ ~/watchpack/~/chokidar/~/fsevents/~/node-pre-gyp/lib/testbinary.js
找不到模块:错误:无法解析模块’child_process’
错误(webpack)/~/watchpack/~/chokidar/~/fsevents/~/forever-agent/index.js
找不到模块:错误:无法解析模块’net’
这是我从package.json的依赖项:
“devDependencies”:{
"babel-core": "^6.4.5",
"babel-loader": "^6.2.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"json-loader": "^0.5.4",
"node-sass": "^3.9.0",
"react": "^15.3.2",
"sass-loader": "^4.0.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.2",
"webpack-bundle-tracker": "0.0.93",
"webpack-dev-server": "^1.15.1"
},
“依赖”:{
"chart.js": "^1.1.1",
"jquery": "^2.2.0",
"material-ui": "^0.15.4",
"react-addons-css-transition-group": "^15.3.1",
"react-bootstrap": "^0.30.3",
"react-chartjs": "^0.8.0",
"react-dom": "^15.3.0",
"react-hot-loader": "^3.0.0-beta.3",
"react-redux": "^4.4.5",
"react-router": "^2.7.0",
"react-sortable-hoc": "0.0.8",
"react-tap-event-plugin": "^1.0.0",
"redux": "^3.6.0"
}
解决方法:
我有同样的问题,实际上你试图在客户端应用服务器模块,解决这个问题,在你的webpack配置客户端添加以下代码:
node: {
fs: "empty",
child_process : "empty",
net : "empty",
}
标签:javascript,npm,webpack,web-deployment 来源: https://codeday.me/bug/20190608/1199034.html