You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行npm install --global eas-cli时触发ERR_INVALID_URL错误求助

安装eas-cli时出现TypeError [ERR_INVALID_URL]问题排查与解决

问题现象

执行npm install --global eas-cli命令时失败,报错TypeError [ERR_INVALID_URL]: Invalid URL。切换至Node.js v21版本后,相同错误依旧出现。

环境信息(Node.js v16)

➜  ~ node -v
v16.20.2
➜  ~ npm -v
8.19.4
➜  ~ npm config get proxy
null
➜  ~ npm config get https-proxy
null
➜  ~ npm config get registry
https://registry.npmjs.org/
➜  ~ npm config get http-proxy
undefined

安装命令执行输出(Node.js v16)

➜  ~ npm install --global eas-cli
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @expo/prebuild-config@6.2.5
npm WARN Found: expo-modules-autolinking@undefined
npm WARN node_modules/eas-cli/node_modules/expo-modules-autolinking
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer expo-modules-autolinking@">=0.8.1" from @expo/prebuild-config@6.2.5
npm WARN node_modules/eas-cli/node_modules/@expo/prebuild-config
npm WARN   @expo/prebuild-config@"6.2.5" from eas-cli@5.9.1
npm WARN   node_modules/eas-cli
npm ERR! code ERR_INVALID_URL
npm ERR! Invalid URL

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/wliu/.npm/_logs/2023-11-24T19_14_48_930Z-debug-0.log

日志文件内容(Node.js v16)

1492 verbose stack TypeError [ERR_INVALID_URL]: Invalid URL
1492 verbose stack     at new NodeError (node:internal/errors:387:5)
1492 verbose stack     at URL.onParseError (node:internal/url:565:9)
1492 verbose stack     at new URL (node:internal/url:641:5)
1492 verbose stack     at getProxyUri (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/make-fetch-happen/lib/agent.js:160:53)
1492 verbose stack     at getAgent (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/make-fetch-happen/lib/agent.js:21:17)
1492 verbose stack     at remoteFetch (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/make-fetch-happen/lib/remote.js:31:17)
1492 verbose stack     at cacheFetch (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/make-fetch-happen/lib/cache/index.js:16:28)
1492 verbose stack     at async fetch (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/make-fetch-happen/lib/fetch.js:98:7)
1492 verbose stack     at async RegistryFetcher.packument (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/pacote/lib/registry.js:92:19)
1492 verbose stack     at async RegistryFetcher.manifest (/Users/wliu/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23)
1493 verbose cwd /Users/wliu/.npm/_logs
1494 verbose Darwin 21.6.0
1495 verbose node v16.20.2
1496 verbose npm  v8.19.4

更新尝试:切换至Node.js v21后问题依旧

环境信息

➜  ~ node -v
v21.2.0
➜  ~ npm -v
10.2.3

安装命令执行输出

➜  ~ npm install --global eas-cli
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @expo/prebuild-config@6.2.5
npm WARN Found: expo-modules-autolinking@undefined
npm WARN node_modules/eas-cli/node_modules/expo-modules-autolinking
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer expo-modules-autolinking@">=0.8.1" from @expo/prebuild-config@6.2.5
npm WARN node_modules/eas-cli/node_modules/@expo/prebuild-config
npm WARN   @expo/prebuild-config@"6.2.5" from eas-cli@5.9.1
npm WARN   node_modules/eas-cli
npm ERR! code ERR_INVALID_URL
npm ERR! Invalid URL

npm ERR! A complete log of this run can be found in: /Users/wliu/.npm/_logs/2023-11-24T19_21_26_890Z-debug-0.log

日志文件内容

1505 timing idealTree:node_modules/eas-cli/node_modules/rimraf/node_modules/glob Completed in 2ms
1506 silly placeDep node_modules/eas-cli/node_modules/rimraf brace-expansion@1.1.11 OK for: minimatch@3.1.2 want: ^1.1.7
1507 timing idealTree:node_modules/eas-cli/node_modules/rimraf/node_modules/minimatch Completed in 1ms
1508 timing idealTree:node_modules/eas-cli/node_modules/rimraf/node_modules/brace-expansion Completed in 0ms
1509 timing idealTree:node_modules/eas-cli/node_modules/supports-hyperlinks/node_modules/supports-color Completed in 0ms
1510 timing idealTree:node_modules/eas-cli/node_modules/tar/node_modules/mkdirp Completed in 0ms
1511 timing idealTree:node_modules/eas-cli/node_modules/tempy/node_modules/type-fest Completed in 0ms
1512 timing idealTree:node_modules/eas-cli/node_modules/xcode/node_modules/uuid Completed in 0ms
1513 timing idealTree:node_modules/eas-cli/node_modules/xml2js/node_modules/xmlbuilder Completed in 0ms
1514 timing idealTree:node_modules/eas-cli/node_modules/@expo/image-utils/node_modules/cross-spawn/node_modules/semver Completed in 0ms
1515 timing idealTree:buildDeps Completed in 1466ms
1516 timing idealTree:fixDepFlags Completed in 3ms
1517 timing idealTree Completed in 1482ms
1518 timing command:install Completed in 1496ms
1519 verbose stack TypeError: Invalid URL
1519 verbose stack     at new URL (node:internal/url:783:36)
1519 verbose stack     at getProxy (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/@npmcli/agent/lib/proxy.js:81:10)
1519 verbose stack     at getAgent (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/@npmcli/agent/lib/index.js:19:23)
1519 verbose stack     at remoteFetch (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/make-fetch-happen/lib/remote.js:37:17)
1519 verbose stack     at cacheFetch (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/make-fetch-happen/lib/cache/index.js:16:28)
1519 verbose stack     at async fetch (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/make-fetch-happen/lib/fetch.js:98:7)
1519 verbose stack     at async RegistryFetcher.packument (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:87:19)
1519 verbose stack     at async RegistryFetcher.manifest (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:118:23)
1519 verbose stack     at async #nodeFromEdge (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1049:19)
1519 verbose stack     at async #loadPeerSet (/Users/wliu/.nvm/versions/node/v21.2.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1310:11)
1520 verbose cwd /Users/wliu
1521 verbose Darwin 21.6.0
1522 verbose node v21.2.0
1523 verbose npm  v10.2.3
1524 error code ERR_INVALID_URL
1525 error Invalid URL
1526 verbose exit 1

解决方案

从日志栈信息分析,问题根源是npm解析代理URL时出错,尽管npm配置显示代理为null,但可能存在环境变量中的代理配置干扰。

  • 步骤1:清空终端代理环境变量
    执行以下命令临时清除终端中的代理环境变量:

    unset HTTP_PROXY
    unset HTTPS_PROXY
    unset http_proxy
    unset https_proxy
    

    之后重新执行安装命令:npm install --global eas-cli

  • 步骤2:强制npm忽略代理
    如果步骤1无效,直接在安装命令中指定无代理:

    npm install --global eas-cli --no-proxy
    
  • 步骤3:重置npm配置
    若问题仍存在,将npm配置重置为默认状态:

    npm config delete proxy
    npm config delete https-proxy
    npm config delete http-proxy
    npm config set registry https://registry.npmjs.org/
    

    随后再次执行安装命令。

  • 步骤4:使用npx临时调用(替代全局安装)
    如果全局安装始终失败,可以直接用npx临时运行eas-cli:

    npx eas-cli@latest <你的命令>
    

内容的提问来源于stack exchange,提问作者LiuWenbin_NO.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 10:45:56