上传 NPM 包时,报: Package name too similar to existing package xxx

2024-09-27 10:53:30

一. 问题

当进行 npm publish 上传 NPM 包时,报以下错误:

npm ERR! code E403 
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/xxx - Package name too similar to existing package xxx; try  
renaming your package to ”xxx“ and publishing with ”npm publish --access=public“ instead 
npm ERR! 403 In most cases, you or one of your dependencies are requesting 
npm ERR! 403 a package version that is forbidden by your security policy, or 
npm ERR! 403 on a server you do not have access to. 

二. 原因和解决方法

包名相似

修改一下包名,即可。

三. 注意事项

包名以@xxx开头时,npm publish会默认发布为私有包, npm 的私有包需要付费

如果你 npm login 的账号不支持私有包,会报以下错误:

npm ERR! code E402
npm ERR! 402 Payment Required - PUT https://registry.npmjs.org/@wangyuegyq%2fparse-markdow - You must sign up for private packages

为解决上面问题,npm publish 发布时,可添加以下参数:

npm publish --access=public 

目录

相关推荐
npm 包登录、发布、删除、查看命令npm 镜像地址更改解决 npm login一直跳转到浏览器构建 NPM 包(一) - 从零开始发布一个简单的 NPM 包npm unpublish 删除包