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

npm install loom-truffle-provider fails with incompatibility of node-gyp vs scrypt

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

node = 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 tring to talk to 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。有些return一个版本号。别人的失败。

~/.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

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

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

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

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

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