当我尝试安装 web3.js 时,出现此错误:
我的系统配置是:
Windows 7
节点:v6.11.0
npm:2010 年 10 月 3 日
npm i ethereum/web3.js --save
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url npm WARN addRemoteGit npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:204:12) npm WARN addRemoteGit at emitTwo (events.js:106:13) npm WARN addRemoteGit at ChildProcess.emit (events.js:191:7) npm WARN addRemoteGit at maybeClose (internal/child_process.js:891:16) npm WARN addRemoteGit at Socket.<anonymous> (internal/child_process.js:342:11) npm WARN addRemoteGit at emitOne (events.js:96:13) npm WARN addRemoteGit at Socket.emit (events.js:188:7) npm WARN addRemoteGit at Pipe._handle.close [as _onclose] (net.js:497:12) npm WARN addRemoteGit ethereum/web3.js resetting remote C:\Users\afeyzi\AppData\Roaming\npm-cache\_git-remotes\git-github-com-ethereum-web3-js-git-6339a8c5 because of error: { Error: Command failed: git -c core.longpaths=true config --get remote.origin.url npm WARN addRemoteGit npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:204:12) npm WARN addRemoteGit at emitTwo (events.js:106:13) npm WARN addRemoteGit at ChildProcess.emit (events.js:191:7) npm WARN addRemoteGit at maybeClose (internal/child_process.js:891:16) npm WARN addRemoteGit at Socket.<anonymous> (internal/child_process.js:342:11) npm WARN addRemoteGit at emitOne (events.js:96:13) npm WARN addRemoteGit at Socket.emit (events.js:188:7) npm WARN addRemoteGit at Pipe._handle.close [as
_onclose] (net.js:497:12) npm WARN addRemoteGit killed: false, npm WARN addRemoteGit code: 1, npm WARN addRemoteGit signal: null, npm WARN addRemoteGit cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
使用以下命令安装 web3 以安装最新版本的 web3(当前为 1.0.0-beta.34)。
npm install web3
此外 --save 标签现在已被弃用,包将作为默认添加到依赖项中。要不在依赖项中包含包,请使用标签 --no-save。
似乎由于 npm 包错误而导致 git 错误, 尝试一下
npm install --save web3@0.20.6
或新版本
npm install --save web3@1.0.0-beta.26
您需要安装适用于 Windows 的 windows-build-tools
npm install --global --production windows-build-tools
解决方案(Linux、Windown7、Windows10)
git 下载并安装
然后,
c:\NodeJs ode_ethereum>npm install web3 --save
npm WARN 已弃用 fs-promise@2.0.3:在 Promise 支持下使用 mz 或 fs-extra^3.0 npm 警告已弃用 tar.gz@1.0.7: ??警告 ?? tar.gz 模块已被弃用,您的应用程序容易受到攻击。请改用 tar 模块:https://npmjs.com/tar npm WARN node_ethereum@1.0.0 无描述 npm WARN node_ethereum@1.0.0 没有存储库字段。
祝你好运!
尝试像这样使用
sudo
sudo npm i web3