Open tree-lock opened 3 years ago
👍
@darkXmo 更新了依赖列表,你可以用 npm@7 试试看安装依赖正常了没有。
@darkXmo 更新了依赖列表,你可以用 npm@7 试试看安装依赖正常了没有。
换了个错误报,过于痛苦,我还是选择 yarn
来安装依赖吧。
npm ERR! code 1
npm ERR! path /home/xmo/code/demo/service-mw2/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@14.17.3 | linux | x64
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/xmo/code/demo/service-mw2/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/xmo/code/demo/service-mw2/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/xmo/code/demo/service-mw2/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/xmo/.node-gyp/14.17.3/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/xmo/.node-gyp/14.17.3',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/xmo/code/demo/service-mw2/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/xmo/.node-gyp/14.17.3/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/xmo/code/demo/service-mw2/node_modules/sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/home/xmo/code/demo/service-mw2/node_modules/node-gyp/lib/configure.js:345:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:375:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Linux 5.10.16.3-microsoft-standard-WSL2
npm ERR! gyp ERR! command "/home/xmo/.nvm/versions/node/v14.17.3/bin/node" "/home/xmo/code/demo/service-mw2/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/xmo/code/demo/service-mw2/node_modules/sqlite3
npm ERR! gyp ERR! node -v v14.17.3
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /home/xmo/.npm/_logs/2021-09-13T08_25_21_464Z-debug.log
这个看上去显示 gyp 的问题
安装 sqlite3 会依赖 node-gyp,windows 平台不大容易装上,可能需要安装 Visual Studio (非VSCode)。你是 MacOS 吧应该没问题。 我这儿 CI 的 alpine 镜像用 npm7 安装是正常的,你可以参考下:
apk add python3
npm config set python /usr/bin/python3
npm i --legacy-peer-deps
npm v6 执行安装(本来用v7然后版本回退改用v6)
此处是 npm@7 错误重现。
虽然应该是 npm 的问题,但还是给遇到相似问题的人一些提示。如果遇到类似问题,
npm install -g npm@6
版本回退即可; 另外,用yarn安装是不会产生问题的。