1

节点版本: 14.17.5

npm 版本: 7.42.0

启动 CI/CD(rush updateyarn命令)时,虚拟机上会出现问题。我认为当我更改节点版本而不重建 npm 包时会发生这种情况。我无法更改节点版本,因为那样会出现其他问题。

如果您使用的是 Windows,要解决此问题,您可以尝试运行:npm install --global --production windows-build-tools然后:npm rebuild node-gyp--> npm install sqlite3。但是,我使用的是 Ubuntu(20.04 lts),所以我尝试构建 nodejs 构建工具,sudo apt-get install -y build-essential然后npm rebuildnpm rebuild node-gyp

我也试过:

  1. npm 卸载 node-pre-gyp
  2. npm 卸载 sqlite3
  3. 再次下载包:
  4. npm i node-pre-gyp -g
  5. npm i sqlite3 -s
  6. 重启实例

还有更多......(npm升级,干净的chache,npm install -g node-gyp

追溯:

les/sqlite3 install: gyp info it worked if it ends with ok
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info using node-gyp@7.1.2
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info using node@14.17.6 | linux | x64
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info ok 
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info it worked if it ends with ok
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info using node-gyp@7.1.2
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info using node@14.17.6 | linux | x64
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
.../node_modules/tiny-secp256k1 install: make: Entering directory '/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/tiny-secp256k1@1.1.6/node_modules/tiny-secp256k1/build'
.../node_modules/tiny-secp256k1 install:   CXX(target) Release/obj.target/secp256k1/native/addon.o
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn /usr/bin/python3
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args [
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '/root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp/gyp/gyp_main.py',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   'binding.gyp',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-f',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   'make',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-I',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/build/config.gypi',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-I',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '/root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp/addon.gypi',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-I',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '/root/.cache/node-gyp/14.17.6/include/node/common.gypi',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dlibrary=shared_library',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dvisibility=default',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/14.17.6',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dnode_gyp_dir=/root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/14.17.6/<(target_arch)/node.lib',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dmodule_root_dir=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Dnode_engine=v8',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '--depth=.',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '--no-parallel',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '--generator-output',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   'build',
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args   '-Goutput_dir=.'
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args ]
.../node_modules/websocket install: make: Entering directory '/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/github.com/web3-js/WebSocket-Node@ef5ea2f41daf4a2113b80c9223df884b4d56c400/node_modules/websocket/build'
.../node_modules/websocket install:   CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info ok 
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info it worked if it ends with ok
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info using node-gyp@7.1.2
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info using node@14.17.6 | linux | x64
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn make
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
.../sqlite3@4.2.0/node_modules/sqlite3 install: make: Entering directory '/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/build'
.../sqlite3@4.2.0/node_modules/sqlite3 install:   ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c
.../sqlite3@4.2.0/node_modules/sqlite3 install: /bin/sh: 1: python: not found
.../sqlite3@4.2.0/node_modules/sqlite3 install: make: *** [deps/action_before_build.target.mk:13: Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c] Error 127
.../sqlite3@4.2.0/node_modules/sqlite3 install: make: Leaving directory '/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/build'
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! build error 
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! stack Error: `make` failed with exit code: 2
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! stack     at ChildProcess.onExit (/root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp/lib/build.js:194:23)
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! System Linux 5.8.0-1041-azure
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! command "/usr/bin/node" "/root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/lib/binding/node-v83-linux-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! cwd /home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! node -v v14.17.6
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! node-gyp -v v7.1.2
.../sqlite3@4.2.0/node_modules/sqlite3 install: gyp ERR! not ok 
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! build error 
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/lib/binding/node-v83-linux-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/node-pre-gyp@0.11.0/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! System Linux 5.8.0-1041-azure
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! command "/usr/bin/node" "/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/node-pre-gyp@0.11.0/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! cwd /home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! node -v v14.17.6
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! node-pre-gyp -v v0.11.0
.../sqlite3@4.2.0/node_modules/sqlite3 install: node-pre-gyp ERR! not ok 
.../sqlite3@4.2.0/node_modules/sqlite3 install: Failed to execute '/usr/bin/node /root/.rush/node-v14.17.6/pnpm-5.18.1/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/user/slave/workspace/app/common/temp/node_modules/.pnpm/sqlite3@4.2.0/node_modules/sqlite3/lib/binding/node-v83-linux-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
.../sqlite3@4.2.0/node_modules/sqlite3 install: Failed
 ERROR  Command failed with exit code 1.

The command failed:
 /home/user/slave/workspace/app/common/temp/pnpm-local/node_modules/.bin/pnpm install --store /home/user/slave/workspace/app/common/temp/pnpm-store --no-prefer-frozen-lockfile
ERROR: Error: The command failed with exit code 1

Giving up after 3 attempts

Deleting the "pnpm-store" folder

ERROR: The command failed with exit code 1

问题仅在虚拟机中,我不知道在哪里可以找到解决此问题的方法。

4

1 回答 1

1

TLDR;

安装/重新安装Python并确保它在您的$Path

sudo apt-get install python3
which python

解释

一、调查

在查看日志时,查找有关哪个部分失败的提示。我注意到这一行:

.../sqlite3@4.2.0/node_modules/sqlite3 install: /bin/sh: 1: python: not found

是否需要python通过构建源代码来通过npm包安装sqlite3?是的

在 npm 上的 sqlite3 的文档中提到了它,您可以阅读以下内容:

默认情况下,node-gyp 安装将使用 python 作为安装的一部分。可以在命令行上指定不同的 python 可执行文件。

npm install --build-from-source --python=/usr/bin/python2

2.修复

所以为了修复它。看来你需要在你$Path的 python 二进制文件中。

要检查你是否有它只是运行:

which python

在我们的例子中,它应该会得到python not found. 我建议您研究如何python为您的操作系统安装。

对于apt依赖管理器的用户(即:Ubuntu,...),它很简单:

sudo apt-get install python3
#check if it is now present in your $Path
which python
于 2021-09-22T10:50:54.360 回答