最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

npm 抛出 npm 错误!代码 EINVALIDPACKAGENAME npm 错误!无效的包名称“授权错误”

网站源码admin32浏览0评论

npm 抛出 npm 错误!代码 EINVALIDPACKAGENAME npm 错误!无效的包名称“授权错误”

npm 抛出 npm 错误!代码 EINVALIDPACKAGENAME npm 错误!无效的包名称“授权错误”

我刚刚安装了 node.js 并尝试从一个 React 项目开始。但是每个 npm 命令(“npm install...”、“npm start”、“npm update -g”)都会抛出我:

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "Authorization Error" of package "Authorization Error@*": name can only contain URL-friendly characters.

我猜它是由包名称“授权错误”中的空格引起的,但我无法在 nodejs 文件或包含此包的 package.json 中找到此包。我再次重新安装了 node.js,但我在所有 npm 安装中都收到此错误消息。这是完整的错误日志。

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 3ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\triroe\.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:C:\Users\triroe\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:setEnvs Completed in 1ms
15 timing config:load Completed in 16ms
16 timing npm:load:configload Completed in 16ms
17 timing npm:load:mkdirpcache Completed in 0ms
18 timing npm:load:mkdirplogs Completed in 0ms
19 verbose title npm update
20 verbose argv "update" "--global"
21 timing npm:load:setTitle Completed in 2ms
22 timing config:load:flatten Completed in 6ms
23 timing npm:load:display Completed in 7ms
24 verbose logfile logs-max:10 dir:C:\Users\triroe\AppData\Local\npm-cache\_logs\2023-04-26T07_32_21_557Z-
25 verbose logfile C:\Users\triroe\AppData\Local\npm-cache\_logs\2023-04-26T07_32_21_557Z-debug-0.log
26 timing npm:load:logFile Completed in 11ms
27 timing npm:load:timers Completed in 0ms
28 timing npm:load:configScope Completed in 1ms
29 timing npm:load Completed in 41ms
30 timing config:load:flatten Completed in 1ms
31 timing arborist:ctor Completed in 0ms
32 silly logfile start cleaning logs, removing 2 files
33 silly logfile done cleaning log files
34 timing idealTree:init Completed in 10ms
35 timing idealTree:userRequests Completed in 3ms
36 silly idealTree buildDeps
37 silly fetch manifest node-red@*
38 http fetch GET 200  460ms (cache miss)
39 silly placeDep ROOT node-red@ OK for:  want: *
40 timing idealTree:#root Completed in 476ms
41 timing idealTree:node_modules/node-red Completed in 0ms
42 timing idealTree:buildDeps Completed in 478ms
43 timing idealTree:fixDepFlags Completed in 1ms
44 timing idealTree Completed in 492ms
45 timing command:update Completed in 504ms
46 verbose stack Error: Invalid package name "Authorization Error" of package "Authorization Error@*": name can only contain URL-friendly characters.
46 verbose stack     at invalidPackageName (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:111:15)
46 verbose stack     at Result.setName (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:158:11)
46 verbose stack     at new Result (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:147:10)
46 verbose stack     at Function.resolve (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\lib\npa.js:59:15)
46 verbose stack     at pickManifest (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-pick-manifest\lib\index.js:88:20)
46 verbose stack     at module.exports (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-pick-manifest\lib\index.js:187:16)
46 verbose stack     at RegistryFetcher.manifest (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\registry.js:119:22)
46 verbose stack     at async [nodeFromEdge] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1059:19)
46 verbose stack     at async [buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:929:11)
46 verbose stack     at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:207:7)
47 verbose cwd C:\Users\triroe\Documents\Workspace\React\udemy-react-project
48 verbose Windows_NT 10.0.19044
49 verbose node v18.16.0
50 verbose npm  v9.5.1
51 error code EINVALIDPACKAGENAME
52 error Invalid package name "Authorization Error" of package "Authorization Error@*": name can only contain URL-friendly characters.
53 verbose exit 1
54 timing npm Completed in 598ms
55 verbose unfinished npm timer reify 1682494341642
56 verbose unfinished npm timer reify:loadTrees 1682494341649
57 verbose code 1
58 error A complete log of this run can be found in:

我也遵循了类似问题的解决方案,通过“npm cache clean –force”,然后从 package.json 中删除了包,但是如何提到我无法在我的节点安装文件中找到包。

回答如下:

检查您是否不在代理网络上。通常这样的网络需要用户名和密码才能运行需要访问互联网的命令。

发布评论

评论列表(0)

  1. 暂无评论