我正在尝试使用npm install安装web3节点包。我知道我首先需要安装Windows构建工具,因为我正在运行Windows:
npm install --global --production windows-build-tools
此命令运行正常,但是当我运行命令安装web3时,我收到以下错误:
npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated tar.gz@1.0.7: ⚠️ WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
> scrypt@6.0.3 preinstall [project path]\node_modules\scrypt
> node node-scrypt-preinstall.js
> scrypt@6.0.3 install [project path]\node_modules\scrypt
> node-gyp rebuild
[project path]\node_modules\scrypt>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Warning: Missing input files:
[project path]\node_modules\scrypt\build\..\scrypt\win\include\config.h
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Copying scrypt/win/include/config.h to scrypt/scrypt-1.2.0/config.h
The system cannot find the file specified.
win_delay_load_hook.cc
LINK : fatal error LNK1181: cannot open input file '[user path]\.node-gyp\9.8.0\x64\node.lib' [[project path]\node_modules\scrypt\build\copied_files.vcxproj]
memlimit.c
keyderivation.c
pickparams.c
hash.c
win_delay_load_hook.cc
scrypt_wrapper.vcxproj -> [project path]\node_modules\scrypt\build\Release\\scrypt_wrapper.lib
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:180:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd [project path]\node_modules\scrypt
gyp ERR! node -v v9.8.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN inbox@1.0.0 No description
npm WARN inbox@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! [user path]\AppData\Roaming\npm-cache\_logs\2018-03-16T15_29_59_737Z-debug.log
在进行了一些关于为什么会发生这种情况的额外研究之后,我发现当安装过程尝试安装scrypt(?)时会弹出错误。 问题是什么?我还添加了Windows构建工具设置后所需的python环境变量。
答案 0 :(得分:0)
要解决此错误,请使用项目属性路径中没有空格或引号的路径。
答案 1 :(得分:0)
很抱歉'因为我无法看到发生了什么以及为什么它不起作用......
我尝试过这种方法对我有用:
正确安装了web 3 V 1.0。
如果其他人可以提供帮助;)
答案 2 :(得分:0)
以root或管理员身份运行可以解决此问题。 我有同样的错误。我遵循Azerus的建议,并创建了仅包含拉丁字母且没有空格的新路径(实际上,我只是创建了新用户并登录)。但是它仍然没有起作用,但是错误号有所不同。然后我想到了以“管理员”身份运行cmd,并且...完成了。