Cli: [BUG] npm unpublish返回错误404,除非使用详细的日志级别,否则不会打印错误

创建于 2020-06-29  ·  14评论  ·  资料来源: npm/cli

什么为什么

npm unpublish不起作用,即使注册表用代码404回答,也不显示任何错误。

什么时候

npm unpublish @siliceum/[email protected] --loglevel verbose

哪里

npm公共注册表

怎么样

当前行为

命令行仅打印

而服务器回答错误404。

另外,端点https://registry.npmjs.org/@siliceum%2fcalcite-cli返回信息,但是带有?write=truehttps://registry.npmjs.org/@siliceum%2fcalcite-cli?write=true )的版本返回未找到错误404。

重现步骤

npm unpublish @siliceum/[email protected]

预期行为

该软件包未发布或打印错误。 (最终,不是404)。
使用冗长的loglevel可以得到以下输出

npm unpublish @siliceum/[email protected] --loglevel verbose

npm信息,如果以ok结尾,则可以正常工作
npm动词cli [
npm动词cli'C:\ Program Files \ nodejs \ node.exe',
npm动词cli'C:\ Program Files \ nodejs \ node_modules \ npm \ bin \ npm-cli.js',
npm动词cli'unpublish',
npm动词cli'@ siliceum / [email protected] ',
npm动词cli'--loglevel',
npm动词cli'verbose'
npm动词cli]
使用[email protected]npm信息
使用[email protected]npm信息
npm动词npm-session e43c8f8257e968e5
npm http获取GET 404 https://registry.npmjs.org/@siliceum%2fcalcite-cli?write = true 492ms

最有用的评论

糟糕! 没关系,我刚刚注销并重新登录,现在这两个功能都正常工作,很奇怪,很抱歉造成混乱!

所有14条评论

npm unpublishnpm deprecate也都存在此问题!

$ npm deprecate --force --verbose [email protected] "Generates errors related to exports in the browser, use 1.2.2 or newer"
...
npm http fetch GET 200 https://registry.npmjs.org/luar?write=true 328ms
npm http fetch PUT 404 https://registry.npmjs.org/luar 98ms
npm verb stack Error: 404 Not Found - PUT https://registry.npmjs.org/luar - Not found
npm verb stack     at /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:114:15
npm verb stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
npm verb statusCode 404
npm verb pkgid [email protected]
...
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/luar - Not found
npm ERR! 404 
npm ERR! 404  '[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
...
$ npm unpublish --force --verbose [email protected]
...
npm http fetch GET 200 https://registry.npmjs.org/luar?write=true 257ms
npm http fetch PUT 404 https://registry.npmjs.org/luar/-rev/5-260b27ca1cdb4a5d3b4175578e1c0300 99ms
npm verb stack Error: 404 Not Found - PUT https://registry.npmjs.org/luar/-rev/5-260b27ca1cdb4a5d3b4175578e1c0300 - Not found
npm verb stack     at /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:114:15
npm verb stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
npm verb statusCode 404
npm verb pkgid [email protected]
...
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/luar/-rev/5-260b27ca1cdb4a5d3b4175578e1c0300 - Not found
npm ERR! 404 
npm ERR! 404  '[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
...

运行npm deprecate遇到相同的问题-找回404 Not Found。 原因是因为我没有通过正确的身份验证( npm adduser进行了排序)-但是“未找到”输出使您无法切线。 即使服务器API不可能返回不同的状态代码(例如401),这些命令的一些输出也将建议登录。 输出可能是通用的,并且始终显示(“确保您已登录!”),或者如果您没有authToken,则可能显示。

但是我已经登录了! 这与我作为软件包所有者发布新版本的终端会话完全相同

糟糕! 没关系,我刚刚注销并重新登录,现在这两个功能都正常工作,很奇怪,很抱歉造成混乱!

@luawtf Ah,在这种情况下,听起来和我的情况相同-当实际问题与身份验证相关时,这些命令显示404 Not Found。

是的我同意,更笼统和冗长的错误将是一个好办法。
另外,为什么在401 Unauthorized更有意义的情况下,注册表会返回404,难道不是也可以解决这个问题吗?

同意对于已经公开的软件包来说似乎有些奇怪-在这种情况下,返回404而不是401并不能确保安全。 如果包是私有的,那将是有道理的,就像GitHub在注销时尝试访问私有存储库时显示404的方式一样,这样就不会遗漏该URL上有任何内容的事实。

我可以确认问题是我尚未登录。
返回401或显示有关未登录的警告消息对我来说都很好。

我们也遇到了一个公共软件包。 npm unpublish @scope/package<strong i="5">@version</strong> --verbose显示404,否则取消发布似乎成功

我有同样的问题,无法将我的软件包打包成deprecate 。 我认为这与确定范围的包有关,因为我注意到包名称中的斜杠在URL中显示为%2f ,但是我真的不明白发生了什么。

$ node -v
v14.15.0
$ npm -v
6.14.8
$ npm deprecate @alling/foo-bar "This package should not be used."
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@alling%2ffoo-bar - Not found
npm ERR! 404 
npm ERR! 404  '@alling/foo-bar<strong i="9">@latest</strong>' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

@SimonAlling npm v7.0.11会发生什么?

@SimonAlling npm v7.0.11会发生什么?

$ docker run -it node bash
# npm -v
7.0.8
# npm login
Logged in as alling on https://registry.npmjs.org/.
npm notice 
npm notice New patch version of npm available! 7.0.8 -> 7.0.11
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.0.11
npm notice Run npm install -g [email protected] to update!
npm notice 
# npm deprecate nonexisting-package-asdfasdf LOL
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/nonexisting-package-asdfasdf?write=true
npm ERR! 404 
npm ERR! 404  'nonexisting-package-asdfasdf<strong i="8">@latest</strong>' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
# npm deprecate @alling/foo-bar "This package should not be used."

即使在大约半个小时后,也没有错误或其他输出,但包页面(即https://www.npmjs.com/package/@alling/foo-bar)上没有出现弃用消息,因此我尝试运行再次命令:

# npm deprecate @alling/foo-bar "This package should not be used."
npm ERR! code E422
npm ERR! 422 Unprocessable Entity - PUT https://registry.npmjs.org/@alling%2ffoo-bar - Unprocessable Entity

但是,如果我转到软件包的特定版本(例如https://www.npmjs.com/package/@alling/foo-bar/v/1.1.6),则会看到预期的弃用消息*。 但我也希望它也显示在主包页面上(例如urix )。

*最新版本:_此已被弃用_。 其他任何版本:_此版本已被弃用_。

编辑:弃用消息最终显示在主软件包页面上。

那是使用npm v7.0.8; 运行deprecate命令之前,您可以npm install -g npm@7吗?

弃用消息最终出现在主软件包页面上,因此我认为它可以与npm v7.0.8一起使用。 :slightly_smiling_face:

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

billop picture billop  ·  3评论

DullReferenceException picture DullReferenceException  ·  4评论

jaydenseric picture jaydenseric  ·  3评论

1000i100 picture 1000i100  ·  3评论

ahuglajbclajep picture ahuglajbclajep  ·  3评论