首先去[npm官网](https://www.npmjs.com/)注册登录验证,也可以使用 npm adduser 注册,不过记得要邮箱验证。
一、登录
npm login // 输入Username Password Email 登录
npm who am i // 查看当前登录的用户
npm login 报错:npm config set registry https://registry.npmjs.org

二、发布
npm publish // 发布包
报错:
// 账号错误
npm ERR! publish Failed PUT 404
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
// 需要绑定的邮箱进行验证
npm ERR! publish Failed PUT 403
npm ERR! you must verify your email before publishing a new package: https://www.npmjs.com/email-edit : npmnodetest
// 使用了淘宝源镜像,需要切换回源镜像
publish Failed PUT 403
npm ERR! code E403
npm ERR! [no_perms] Private mode enable, only admin can publish this module [no_perms] Private mode enable, only admin can publish this module: v-data-calendar
npm config set registry https://registry.npm.taobao.org // 全局切换淘宝源镜像
npm config set registry http://www.npmjs.org // 全局切换到源镜像
npm info underscore // 检测是否切换到淘宝源
未登录下 npm publish:

三、成功

四、删除
npm unpublish 包名@版本号
npm unpublish 包名@版本号 – --force // 强制删除
本文详细介绍了如何在npm上注册、登录、发布和管理软件包。包括解决常见错误,如账号验证、权限问题和源镜像切换。适用于初次接触npm的开发者。

1805

被折叠的 条评论
为什么被折叠?



