从 Node v5.1.0 升级到 v12.16.1 运行 出错

Upgrading from Node v5.1.0 to v12.16.1 running into error

我正在恢复一个旧的 Node 项目,.nvmrc 是 v5.1.0。我使用 nvm 开始使用 v12.16.1,现在当我 运行 npx inpm i 时,我得到以下输出:

https://gist.github.com/ruevaughn/1d465d509aa04800954d43da4ef581c7

我可以从该要点中得出的主要信息在这里:

18 warnings and 18 errors generated.
make: *** [Release/obj.target/bcrypt_lib/src/bcrypt_node.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/cjensen/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/Users/cjensen/.nvm/versions/node/v12.16.1/bin/node" "/Users/cjensen/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/cjensen/projects/inusa/inusa-api/node_modules/bcrypt
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN eslint-config-airbnb@12.0.0 requires a peer of eslint-plugin-import@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb-base@8.0.0 requires a peer of eslint-plugin-import@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN The package loopback-testing-helpers is included as both a dev and production dependency.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@0.8.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.7 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!     /Users/cjensen/.npm/_logs/2020-02-25T20_43_56_990Z-debug.log

这里是2020-02-25T20_43_56_990Z-debug.log


我尝试手动 运行 node-gyp 并收到以下错误:

    ~/p/inu/inusa-api    update-node +1 !1 ?1 ▓▒░ node-gyp rebuild                                ░▒▓ ✔  30m 58s   12.16.1   14:41:49  
gyp info it worked if it ends with ok
gyp info using node-gyp@6.1.0
gyp info using node@12.16.1 | darwin | x64
gyp info find Python using Python version 3.7.5 found at "/usr/local/opt/python/bin/python3.7"
gyp info spawn /usr/local/opt/python/bin/python3.7
gyp info spawn args [
gyp info spawn args   '/Users/cjensen/.nvm/versions/node/v5.1.0/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/cjensen/projects/inusa/inusa-api/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/cjensen/.nvm/versions/node/v5.1.0/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/cjensen/Library/Caches/node-gyp/12.16.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/cjensen/Library/Caches/node-gyp/12.16.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/cjensen/.nvm/versions/node/v5.1.0/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/cjensen/Library/Caches/node-gyp/12.16.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/cjensen/projects/inusa/inusa-api',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: binding.gyp not found (cwd: /Users/cjensen/projects/inusa/inusa-api) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/cjensen/.nvm/versions/node/v5.1.0/lib/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/Users/cjensen/.nvm/versions/node/v12.16.1/bin/node" "/Users/cjensen/.nvm/versions/node/v5.1.0/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/cjensen/projects/inusa/inusa-api
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok

显然不行。所以,在我看来,node-gyp 是用节点 v6.10 编译的(在我决定 'go for it' 之前,我最初是从 5 升级到 6)。

当我做

which -a node-gyp                                      
/Users/cjensen/.nvm/versions/node/v5.1.0/bin/node-gyp

我看到节点 V5.1.0 是它当前设置的路径。我做错了什么?

您似乎使用的是旧版本的 bcrypt (0.8.7)。您需要至少使用版本 3.0.6 才能使用 Node 12。

https://www.npmjs.com/package/bcrypt#version-compatibility