npm install loom-truffle-provider 因 node-gyp 与 scrypt 不兼容而失败

Posted

技术标签:

【中文标题】npm install loom-truffle-provider 因 node-gyp 与 scrypt 不兼容而失败【英文标题】:npm install loom-truffle-provider fails with incompatibility of node-gyp vs scrypt 【发布时间】:2021-12-25 05:53:21 【问题描述】:

我在安装 loom-truffle-provider 时遇到了无穷无尽的麻烦。

节点 = v14.18.1 npm = 6.14.15 Linux Ubuntu 20.04

我可以尝试在本地或全局安装。两者都失败并出现以下错误:

~$ npm install -g loom-truffle-provider

make: Leaving directory '/home/joe/.npm-global/lib/node_modules/loom-truffle-provider/node_modules/scrypt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Linux 5.11.0-40-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/joe/.npm-global/lib/node_modules/loom-truffle-provider/node_modules/scrypt
gyp ERR! node -v v14.18.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
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!     /home/joe/.npm/_logs/2021-11-12T22_49_07_516Z-debug.log

但进一步查找消息,我看到如下行:

/home/joe/.cache/node-gyp/14.18.1/include/node/v8.h:3673:37: note:   candidate expects 3 arguments, 2 provided
../src/node-boilerplate/scrypt_params_async.cc:25:64: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>, Nan::imp::IntegerFactory<v8::Integer>::return_t)’
   25 |   obj->Set(Nan::New("p").ToLocalChecked(), Nan::New<Integer>(p));
      |                                                                ^

大约有 9 个这样的错误,都是从 node-gyp 到 scrypt 的。

我四处寻找所有出现的 node-gyp。例如, ~/.cache 有:

joe@joeslinux:~/.cache/node-gyp
$ ls -al
total 24
drwxrwxr-x  6 joe joe 4096 Oct 25 19:24 .
drwxr-xr-x 37 joe joe 4096 Oct 27 19:21 ..
drwxrwxr-x  3 joe joe 4096 Aug 24 11:37 10.19.0
drwxrwxr-x  3 joe joe 4096 Oct 25 19:24 14.18.1
drwxrwxr-x  3 joe joe 4096 Sep  4 09:45 16.8.0
drwxrwxr-x  3 joe joe 4096 Sep 19 12:43 16.9.1

我清除了 ~/.cache/node-gyp 中的所有内容并重新运行 ~/.cache/node-gyp 仍然遇到相同的错误,但现在 ~/.cache/node-gyp$ 是

joe@joeslinux:~/.cache/node-gyp$ ls -al
total 12
drwxrwxr-x  3 joe joe 4096 Nov 12 17:49 .
drwxr-xr-x 37 joe joe 4096 Oct 27 19:21 ..
drwxrwxr-x  3 joe joe 4096 Nov 12 17:49 14.18.1

因此,这将由 npm install 重建 我到处都有不同版本的node-gyp。有些返回版本号。别人的失败。

~/.npm-global/bin/node-gyp --version
v8.4.0

usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp --version
internal/modules/cjs/loader.js:905
  throw err;
  ^

/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp --version
v5.1.0


/usr/local/n/versions/node/14.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp --version
internal/modules/cjs/loader.js:905
  throw err;
  ^

/usr/local/n/versions/node/14.18.1/lib/node_modules/npm/bin/node-gyp-bin/node-gyp --version
v5.1.0

/usr/bin/node-gyp --version
internal/modules/cjs/loader.js:905
  throw err;
  ^

/usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp --version
'internal/modules/cjs/loader.js:905
  throw err;
  ^

I am at a loss how to proceed. I know from reading other threads that node-gyp has this known issue. I tried several workarounds and do not work for me. The error lines state that npm uses node-gyp v5.1.0. How do I get it to try v8.4.0?

我尝试了以下建议:

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

NPM modules won't install globally without sudo

https://ethereum.stackexchange.com/questions/86783/linux-node-gyp-installation-woes-in-scrypt-package

所有这些帖子应该已经解决了我特定计算机上的问题,但到目前为止还没有任何乐趣。一个建议恢复到节点的先前版本。该帖子指的是从节点 12.16.1 恢复到节点 11。但我已经在 14.8.1 上。我不认为根据一岁的帖子从 14 岁回到 11 岁对我来说是明智的。 其他帖子提到“有些东西是不兼容的”。好吧,我想我发现至少第一件事不相容。我将如何解决它?抱歉,仍然处于 Linux 学习曲线的陡峭部分。 是否有任何 node-gyp 人或 scrypt 人关注这些帖子?

完整的日志位于 https://github.com/molnarjoe/myGitRepository/blob/master/2021-11-12T22_49_07_516Z-debug.log

【问题讨论】:

【参考方案1】:

scrypt 包已弃用,并且与 node v14 不兼容。

您可以尝试将 loom-truffle-provider 升级到 0.15.00.16.0

查看https://github.com/loomnetwork/loom-truffle-provider/issues/12#issuecomment-853959947

【讨论】:

谢谢@banyuda。做到了。

以上是关于npm install loom-truffle-provider 因 node-gyp 与 scrypt 不兼容而失败的主要内容,如果未能解决你的问题,请参考以下文章

npm install -save 和npm install -save-dev 给你好看

npm install --save 和 npm install -d的区别

运行 npm install cordova 时 npm install 不起作用

npm install -g 和npm install --save-dev的关系

npm install --save 与 npm install --save-dev 的区别

npm install --save 与 npm install --save-dev 的区别