Jonathan Star 2025-01-03 16:10 采纳率: 69.9%
浏览 57

node-gyp install 用的源是哪里配置的

node-gyp install 用的源是哪里配置的

他去使用 `https://npm.taobao` 了,

但是我已经配置了下面

D:\software\nvm\v18.20.4>npm config set registry https://registry.npmmirror.com/

D:\software\nvm\v18.20.4>pnpm config set registry https://registry.npmmirror.com/

也配置了

C:\Users\xxx\.npmrc
registry=https://mirrors.huaweicloud.com/repository/npm/
他是从哪里得知要去https://npm.taobao.org  的呀

问题

│ gyp ERR! stack FetchError: request to https://npm.taobao.org/dist/v18.20.4/node-v18.20.4-headers.tar.gz failed, reason: Hostname/IP does not match certificate's altnames: Host: npm.taobao.org. is not in the cert's altn…  

log

e-js: Running postinstall script, done in 244ms
node_modules/.pnpm/mongodb-memory-server@10.1.0_socks@2.8.3/node_modules/mongodb-memory-server: Running postinstall script...
node_modules/.pnpm/mongodb-memory-server@9.2.0/node_modules/mongodb-memory-server: Running postinstall script...
node_modules/.pnpm/isolated-vm@4.7.2/node_modules/isolated-vm: Running install script, failed in 21.9s
.../node_modules/isolated-vm install$ prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)
│ prebuild-install warn install connect ETIMEDOUT 20.205.243.166:443
│ D:\proj\python\FastGPT\node_modules\.pnpm\isolated-vm@4.7.2\node_modules\isolated-vm>if not defined npm_config_node_gyp (node "D:\software\nvm\v18.20.4\node_modules\pnpm\dist\node-gyp-bin\\..\node_modules\node-gyp\bin\…  
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@10.2.0
│ gyp info using node@18.20.4 | win32 | x64
│ gyp info find Python using Python version 3.11.7 found at "D:\env\anaconda3\python.exe"
│ gyp http GET https://npm.taobao.org/dist/v18.20.4/node-v18.20.4-headers.tar.gz
│ gyp http fetch GET https://npm.taobao.org/dist/v18.20.4/node-v18.20.4-headers.tar.gz attempt 1 failed with ERR_TLS_CERT_ALTNAME_INVALID
│ gyp WARN install got an error, rolling back install
│ gyp ERR! configure error 
│ gyp ERR! stack FetchError: request to https://npm.taobao.org/dist/v18.20.4/node-v18.20.4-headers.tar.gz failed, reason: Hostname/IP does not match certificate's altnames: Host: npm.taobao.org. is not in the cert's altn…  
│ gyp ERR! stack at ClientRequest.<anonymous> (D:\software\nvm\v18.20.4\node_modules\pnpm\dist\node_modules\minipass-fetch\lib\index.js:130:14)
│ gyp ERR! stack at ClientRequest.emit (node:events:517:28)
│ gyp ERR! stack at _destroy (node:_http_client:882:13)
│ gyp ERR! stack at onSocketNT (node:_http_client:902:5)
│ gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
│ gyp ERR! System Windows_NT 10.0.19045
│ gyp ERR! command "D:\\env\\nodejs\\node.exe" "D:\\software\\nvm\\v18.20.4\\node_modules\\pnpm\\dist\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release" "-j" "max"
│ gyp ERR! cwd D:\proj\python\FastGPT\node_modules\.pnpm\isolated-vm@4.7.2\node_modules\isolated-vm
│ gyp ERR! node -v v18.20.4
│ gyp ERR! node-gyp -v v10.2.0
│ gyp ERR! not ok 
└─ Failed in 21.9s at D:\proj\python\FastGPT\node_modules\.pnpm\isolated-vm@4.7.2\node_modules\isolated-vm
node_modules/.pnpm/canvas@2.11.2_encoding@0.1.13/node_modules/canvas: Running install script, failed in 22s (skipped as optional)
 ELIFECYCLE  Command failed with exit code 1.
  • 写回答

2条回答 默认 最新

  • 檀越@新空间 2025-01-03 16:15
    关注

    下午好🌅🌅🌅
    本答案参考通义千问

    从你的描述来看,node-gyp 在安装过程中仍然尝试从 https://npm.taobao.org 下载文件,尽管你已经配置了不同的 registry。这可能是因为某些包的安装脚本中硬编码了特定的下载地址,或者是在某些配置文件中存在旧的配置。

    以下是一些可能的解决方案:

    1. 检查全局配置和本地配置: 确认全局和本地的 npm 配置是否正确。

      npm config get registry
      cat ~/.npmrc
      
    2. 清理 npm 缓存: 清理 npm 缓存以确保没有旧的配置残留。

      npm cache clean --force
      
    3. 检查包的安装脚本: 检查相关包的 package.jsonpreinstall/postinstall 脚本,确认是否有硬编码的下载地址。

    4. 修改或删除 .npmrc 文件: 确认 .npmrc 文件中的配置是否正确,并且没有重复或冲突的配置。

      registry=https://mirrors.huaweicloud.com/repository/npm/
      
    5. 更新 node-gyp 和相关工具: 确保 node-gyp 和相关工具是最新的版本。

      npm install -g node-gyp
      
    6. 使用代理或镜像服务: 如果必须使用特定的镜像服务,可以尝试在安装时指定代理。

      npm config set proxy http://your-proxy-url:port
      npm config set https-proxy http://your-proxy-url:port
      
    7. 检查环境变量: 确认没有设置相关的环境变量影响 npm 的行为。

      echo %HTTP_PROXY%
      echo %HTTPS_PROXY%
      

    以下是具体的命令步骤:

    步骤 1:检查配置

    npm config get registry
    cat ~/.npmrc
    

    步骤 2:清理缓存

    npm cache clean --force
    

    步骤 3:更新 node-gyp

    npm install -g node-gyp
    

    步骤 4:检查 .npmrc 文件

    确保 .npmrc 文件内容如下:

    registry=https://mirrors.huaweicloud.com/repository/npm/
    

    步骤 5:使用代理(如果需要)

    npm config set proxy http://your-proxy-url:port
    npm config set https-proxy http://your-proxy-url:port
    

    步骤 6:检查环境变量

    echo %HTTP_PROXY%
    echo %HTTPS_PROXY%
    

    通过以上步骤,你应该能够解决 node-gyp 使用错误的源的问题。如果问题仍然存在,请检查具体包的安装脚本或配置文件。

    评论

报告相同问题?

问题事件

  • 创建了问题 1月3日