NodeJS 每个npm安装都会给出“npm错误!仅支持绝对URL”

jqjz2hbq  于 2023-01-30  发布在  Node.js
关注(0)|答案(1)|浏览(384)

已尝试运行最新npm 6.4.1的 NodeJS 8.12和10.11
当尝试安装任何软件包,即(npm install -g firebase-tools)时,我得到npm ERR! Only absolute URLs are supported.
卸载并重新安装nodeJS。仍然损坏。任何帮助表示感谢。
调试日志

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'firebase-tools' ]
2 info using npm@6.4.1
3 info using node@v10.11.0
4 verbose npm-session 442f99e3eed77ef2
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for firebase-tools@latest Only absolute URLs are supported
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 206ms
10 verbose stack TypeError: Only absolute URLs are supported
10 verbose stack     at getNodeRequestOptions (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\request.js:131:11)
10 verbose stack     at fetch.Promise (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:44:21)
10 verbose stack     at new Promise (<anonymous>)
10 verbose stack     at fetch (C:\Program 
Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:41:10)
10 verbose stack     at retry (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\index.js:332:14)
10 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\promise-retry\index.js:29:24
11 verbose cwd C:\Users\Mine
12 verbose Windows_NT 10.0.17134
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
14 verbose node v10.11.0
15 verbose npm  v6.4.1
16 error Only absolute URLs are supported
17 verbose exit [ 1, true ]
rxztt3cl

rxztt3cl1#

Solution moved来自@StevePerry的问题帖子。
必须编辑位于C:\Users\yourName\.npmrc.npmrc文件
有很多台词。只有我需要的:

//registry.npmjs.org/:_authToken="your_auth_token"
scope="your_name"
@"your_name":registry=https://registry.npmjs.org/

相关问题