Webpack,枪,无法解决文件等,枪要求无法解决模块'FS'
我正在与gundb电子应用程序。在所有其他工作后,我做了一个npm install --save gun
。它完成了这个警告:Webpack,枪,无法解决文件等,枪要求无法解决模块'FS'
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
当我尝试:
require('gun');
var endpoints;
var gun = Gun(endpoints);
我得到一个非常长的错误,因为我不能做的名单。他们先从:
.../node_modules/fs doesn't exist
.../node_modules/fs.webpack.js doesn't exist
.../node_modules/fs.web.js doesn't exist
.../node_modules/fs.js doesn't exist
.../node_modules/fs.json doesn't exist
及以下不能解析:
@ ./~/gun/lib/file.js 14:10-23
@ ./~/gun/lib/wsp.js 61:39-52
@ ./~/ws/lib/WebSocketServer.js 15:10-2
@ ./~/options/lib/options.js 6:9-2
@ ./~/aws-sdk/lib/api_loader.js 1:9-22
@ ./~/aws-sdk/lib/services.js 1:9-22
我在Linux上。是否fsevent枪npm的依赖?
UPDATE
要删除许多其它变量可能,我减少了我的package.json文件下降到仅电子....消除了可能的WebPack问题和其他依赖。我也删除了我的node_modules并做了一个新的npm install & npm install gun
。
这透露了更多有用的错误:
Uncaught ReferenceError: Gun is not defined gun.js:1470
其中指出:
if(typeof window !== "undefined"){ Gun.request = request }
if(typeof module !== "undefined" && module.exports){ module.exports.request = request }
这是一个错误的枪和枪队今天上午纠正它。后该错误已得到纠正,我在我的项目更新的枪,我还是留下了与捆绑的WebPack问题:
WARNING in ./~/ws/lib/BufferUtil.js
Module not found: Error: Cannot resolve module 'bufferutil' in /node_modules/ws/lib
@ ./~/ws/lib/BufferUtil.js 10:19-40
WARNING in ./~/ws/lib/Validation.js
Module not found: Error: Cannot resolve module 'utf-8-validate' in /node_modules/ws/lib
@ ./~/ws/lib/Validation.js 10:19-44
WARNING in ./~/formidable/lib/incoming_form.js
Critical dependencies:
1:43-50 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/formidable/lib/incoming_form.js 1:43-50
WARNING in ./~/formidable/lib/file.js
Critical dependencies:
1:43-50 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/formidable/lib/file.js 1:43-50
WARNING in ./~/formidable/lib/json_parser.js
Critical dependencies:
1:43-50 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/formidable/lib/json_parser.js 1:43-50
WARNING in ./~/formidable/lib/querystring_parser.js
Critical dependencies:
1:43-50 require function is used in a way in which dependencies cannot be statically extracted
@ ./~/formidable/lib/querystring_parser.js 1:43-50
WARNING in ./~/aws-sdk/lib/util.js
Critical dependencies:
40:30-45 the request of a dependency is an expression
43:11-53 the request of a dependency is an expression
@ ./~/aws-sdk/lib/util.js 40:30-45 43:11-53
WARNING in ./~/aws-sdk/lib/api_loader.js
Critical dependencies:
13:15-59 the request of a dependency is an expression
104:12-46 the request of a dependency is an expression
108:21-58 the request of a dependency is an expression
114:18-52 the request of a dependency is an expression
@ ./~/aws-sdk/lib/api_loader.js 13:15-59 104:12-46 108:21-58 114:18-52
我有以下添加到我的webpack.config.js使用枪的WebPack:
var webpack = require('webpack');
module.exports = {
devtool: "source-map",
target: "node",
....
module: {
noParse: [/aws-sdk/],
....
plugins: [
new webpack.DefinePlugin({ "global.GENTLY": false })
]
....
此时一切都甚至工作,虽然我仍然在bash以下错误:
WARNING in ./~/ws/lib/BufferUtil.js
Module not found: Error: Cannot resolve module 'bufferutil' in /node_modules/ws/lib
@ ./~/ws/lib/BufferUtil.js 10:19-40
WARNING in ./~/ws/lib/Validation.js
Module not found: Error: Cannot resolve module 'utf-8-validate' in /node_modules/ws/lib
@ ./~/ws/lib/Validation.js 10:19-44
太棒了!很高兴听到我们推动的解决方案解决了主要问题。希望最终我们也可以让这些最后几个烦人的WARNING/ERROR消息消失。感谢您的回答,非常感谢! – marknadal
由于这是@marknadal和朋友正在处理的已知问题,因此我继续使用'stats:{warnings:false}'作为减少噪音的肮脏解决方案。 – aleksblago
@aleksblago哦,这是什么帮助/解决了这个问题呢?我要添加关于require('gun/gun')的另一个答案; – marknadal
现在,在浏览器中,你应该:
var Gun = require('gun/gun');
解决您的问题。或者使用脚本标记,它在全局范围内导出Gun。
在未来,我们会努力和有需要(“枪”)自动检测环境,而不是自动包含唯一的NodeJS代码(如fs
,的WebSockets,HTTP等)
这fsevent警告很正常。他们没有关系。 –
这个问题也可能对其他Webpack/GUN错误有帮助(对于那些从Google点击这个问题的人,但这不是正确的问题):http://*.com/questions/39001582/running-gunjs-with -reactjs-and-webpack-throws-reference-error-in-console/39003291#39003291 – marknadal