我正在尝试在 macosx 上开始使用 Ethereum Web3.js 和节点 6.11.1
我使用以下命令安装了 web3:
npm 安装 web3
然后我启动这个 - 显然 - 简单的节点命令:
Web3 = require(‘web3’);
那么,它返回以下错误:
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)
看起来它需要一些未随包安装的模块(例如“web3-requestManager”)。
这是我的 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"
}
任何想法?难道我做错了什么?
原文由 Umberto Stanca 发布,翻译遵循 CC BY-SA 4.0 许可协议
问题来自使用 web3 的 beta 版本,它目前不稳定,目前正在大力开发中,您有两个选择之一,
要么使用我认为的稳定版本 0.23 或类似的版本
或手动安装所有需要的依赖项我不推荐此解决方案用于稳定的 dapp,因为目前情况确实不稳定