以太坊web3.js傳回不能找到子產品web3-requestManager?錯誤資訊如下:
Cannot find module ‘web3-requestManager’
我用下面指令安裝web3:
npm install web3
然後我啟動了node.js的指令,很簡單的:
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"
}
這個問題來自使用Web3的beta版本,它不穩定,不過目前已經釋出1.0版本了,你有兩個選項:
- 要麼使用一個穩定的版本0.23/1.0
- 或手動安裝所有需要的依賴關系,我不建議這個解決方案,因為很不穩定
原文:
http://cw.hubwiz.com/card/c/ethereum-FAQ/1/2/3/另外推薦一些之前的教程: