【问题标题】:Fatal error LNK1181 when trying to npm install web3尝试 npm install web3 时出现致命错误 LNK1181
【发布时间】:2018-08-29 12:10:36
【问题描述】:

我正在尝试使用 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 环境变量。

【问题讨论】:

    标签: javascript typescript npm web3


    【解决方案1】:

    要解决此错误,请在项目属性的路径中使用不带空格或引号的路径。

    【讨论】:

    • 什么意思?如果您的意思是项目路径应该没有空格,我已经尝试过了,它不起作用。
    • 好的,首先尝试清除您的 npm 缓存“npm cache verify”(如果您使用的是 npm v5+)或旧版本的“npm cache clean”。尝试使用此命令“npm install --global --production windows-build-tools (Administrator privilege)”以管理员权限进行全局安装后
    • 遗憾的是,它仍然不起作用,我已经尝试了几次该选项。我可以补充一点,我可以安装旧版本的 web3,但最新版本给了我这个错误。我正在使用以下命令进行安装:“npm install --save web3@1.0.0-beta.26”
    【解决方案2】:

    非常抱歉,因为我看不到发生了什么以及为什么它不起作用......

    我试过了,用这种方法对我有用:

    1. npm install --global --production windows-build-tools
    2. npm install --save web3@1.0.0-beta.26

    并且 web 3 V 1.0 已正确安装。

    如果其他人可以提供帮助;)

    【讨论】:

      【解决方案3】:

      以 root 或管理员身份运行可以解决问题。 我有同样的错误。我按照 Azerus 的建议创建了只有拉丁字母且没有空格的新路径(实际上我只是创建了新用户并登录)。但它仍然不起作用,但错误号不同。然后我想到了以管理员身份运行 cmd 并且......它完成了。

      【讨论】:

      • 简单地运行具有更高权限的东西有时可能是正确的解决方案。但这也很危险。因此,除非您知道自己在做什么,否则通常不鼓励这样做。
      猜你喜欢
      • 2019-05-10
      • 2018-07-08
      • 2021-11-25
      • 2023-02-04
      • 2019-02-27
      • 1970-01-01
      • 2022-01-05
      • 2020-02-20
      • 2021-10-26
      相关资源
      最近更新 更多