[英]Ethereum Web3.js returns “Cannot find module 'web3-requestManager'”
I'm trying to start using Ethereum Web3.js with node 6.11.1 on a macosx 我正在尝试在macosx上开始使用带有节点6.11.1的Ethereum Web3.js
I installed web3 with the following command: 我使用以下命令安装了web3:
npm install web3
npm安装web3
Then i launch this - apparently - simple node command: 然后我启动这个 - 显然 - 简单的节点命令:
Web3 = require('web3');
Web3 = require('web3');
Well, it returns the following error: 好吧,它返回以下错误:
module.js:471
throw err;
^
Error: Cannot find module 'web3-requestManager'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/fremente/Dropbox/Influx Design/Web htdocs/ethereum/node_modules/web3/packages/web3-core/src/index.js:26:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
it looks like it require some module (eg 'web3-requestManager') that aren't installed with the package. 看起来它需要一些未随包安装的模块(例如'web3-requestManager')。
Here it is my package.json 这是我的package.json
{
"name": "ethereum",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"ethereumjs-testrpc": "^4.0.1",
"solc": "^0.4.13",
"web3": "^1.0.0-beta2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Any Idea? 任何的想法? Am i doing something wrong?
难道我做错了什么?
npm install ethereum/web3.js
应该解决你的问题
The problem comes from using a beta version of web3 its not stable at the moment and currently is under heavy development you have one of two options, 问题来自于使用测试版的web3,目前还不稳定,目前正处于大量开发阶段,你有两种选择之一,
either use a stable version 0.23 i think or something like that 使用稳定版本0.23我认为或类似的东西
or manually install all the needed dependencies i don't recommend this solution for a stable dapp since things are currently really unstable 或手动安装所有需要的依赖项我不推荐这个解决方案用于稳定的dapp,因为目前事情确实很不稳定
I solved it by removing node_modules
folder, running npm install
again and installing web3js
manually in addition to package.json
listing: 我通过删除
node_modules
文件夹,再次运行npm install
并手动安装web3js
以及package.json
列表解决了这个问题:
Add dependency to package.json 向package.json添加依赖项
"web3": "^1.0.0-beta.31"
Rebuild modules 重建模块
rm -rf node_modules
npm install
Install web3 manually 手动安装web3
npm install web3@1.0.0-beta.31
I was facing this exact issue with: web3@1.0.0-beta.26
我正面临着这个问题:
web3@1.0.0-beta.26
I have fixed this issue by upgrading node from v6.11.3
to v8.9.4
. 我已经通过升级节点从修复了这个问题
v6.11.3
到v8.9.4
。
I have removed node_modules
folder and run: npm install
to rebuild modules. 我删除了
node_modules
文件夹并运行: npm install
来重建模块。
I think that web3 is using features that are only supported by node version 8.xx 我认为web3使用的只是节点版本8.xx支持的功能
I resolved the web3-requestManager
issue by pinning to 1.0.0-beta.29
version. 我通过固定到
1.0.0-beta.29
版本解决了web3-requestManager
问题。 Previously it was installing 1.0.0-beta.2
. 以前它安装的是
1.0.0-beta.2
。
Installing git on my Windows 10 machine helped. 在我的Windows 10机器上安装git有帮助。 Dependencies did not install properly without it.
没有它,依赖关系没有正确安装。 https://git-scm.com/downloads
https://git-scm.com/downloads
I am currently using web3 1.0 version. 我目前正在使用web3 1.0版本。 And I am using macOS as well.
我也在使用macOS。 If you are using this version too, try this:
如果您也使用此版本,请尝试以下操作:
Running npm install ethereum/web3.js
npm install ethereum/web3.js
fixed my issue. npm install ethereum/web3.js
解决了我的问题。
hope it works for you too. 希望它也适合你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.