我目前正在努力将服务从节点 14 升级到节点 20.9.0,我这样做了,我更新了 docker 文件和 nvmrc 文件等,但是当我尝试使用节点 20.9.0 进行 npm install 时,我得到了这些错误非常令人沮丧,我找不到修复它们的方法,请问有什么想法吗?
npm ERR! path /Users/faljawhary/Desktop/forks/pkg-transformations/node_modules/node-expat
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 [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.9.0/node-v20.9.0-headers.tar.gz
npm ERR! (node:22309) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
npm ERR! (Use `node --trace-warnings ...` to show where the warning was created)
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v20.9.0/node-v20.9.0-headers.tar.gz failed, reason:
npm ERR! gyp ERR! stack at ClientRequest.<anonymous> (/Users/faljawhary/.nvm/versions/node/v20.9.0/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm ERR! gyp ERR! stack at ClientRequest.emit (node:events:514:28)
npm ERR! gyp ERR! stack at TLSSocket.socketErrorListener (node:_http_client:495:9)
npm ERR! gyp ERR! stack at TLSSocket.emit (node:events:526:35)
npm ERR! gyp ERR! stack at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR! gyp ERR! stack at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! gyp ERR! System Darwin 23.2.0
npm ERR! gyp ERR! command "/Users/faljawhary/.nvm/versions/node/v20.9.0/bin/node" "/Users/faljawhary/.nvm/versions/node/v20.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/faljawhary/Desktop/forks/pkg-transformations/node_modules/node-expat
npm ERR! gyp ERR! node -v v20.9.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in: /Users/faljawhary/.npm/_logs/2023-12-26T17_28_54_829Z-debug-0.log
我尝试在我的 MAC 上安装 Python,并尝试了以下命令:
pyenv install 2.7.18
pyenv global 2.7.18
export PATH="${HOME}/.pyenv/shims:${PATH}"
echo $PATH
npm config set python $(which python)
npm config list
错误从“未找到Python”更改为我上面刚刚提到的这些新错误。
如果你可以用
yarn add
代替你可能会有更好的运气。
我昨天在尝试通过
shrink-ray-current
安装 npm 包 npm i shrink-ray-current --save
时遇到了这个问题。 node-gyp
是该包的依赖项,它导致了与您所遇到的类似错误。我用 npm 尝试了几件事,例如,但都没有成功。我不知道具体细节,但 Yarn 处理依赖关系解析的方式与 npm 不同。