发布npm包踩坑

昨天试着发布npm包,遇到了问题,记录一下。npm

一:首先必须注册npm帐号json

用npm adduser 命令this

npm ERR! code EAUTHUNKNOWN
npm ERR! Unable to authenticate, need: Basic
把npm升级到6.9.0 ,报另外一个错
npm ERR! code E401
    npm ERR! Incorrect or missing password.
    npm ERR! If you were trying to login, change your password, create an
    npm ERR! authentication token or enable two-factor authentication then
    npm ERR! that means you likely typed your password in incorrectly.
    npm ERR! Please try again, or recover your password at:
    npm ERR! https://www.npmjs.com/forgot
    npm ERR!
    npm ERR! If you were doing some other operation then your saved credentials are
    npm ERR! probably out of date. To correct this please try logging in again with:
    npm ERR!     npm login

继续百度,表面看样子是我密码不正确,其实由于重定向了npm库的源,因此npm adduser时会将用户名和密码提交到http://registry.npm.taobao.org 去验证spa

因而切源 到cnpm。

clipboard.png

继续npm adduser,此次就有用户名、邮箱的提示。debug

clipboard.png

最后一句话看样子是成功了3d

执行命令 npm publish 发布

结果报错code

$ npm publish
npm notice
npm notice package: lx@1.0.0
npm notice === Tarball Contents ===
npm notice 435B package.json
npm notice === Tarball Details ===
npm notice name:          lx
npm notice version:       1.0.0
npm notice package size:  324 B
npm notice unpacked size: 435 B
npm notice shasum:        60f600a893d64ddc1e71a4707c7de7f5974bcb01
npm notice integrity:     sha512-y16NeHDVs1aLk[...]WU0yjiaIvJD4g==
npm notice total files:   1
npm notice
npm ERR! code E403
npm ERR! 403 Forbidden - PUT http://r.cnpmjs.org/lx - [no_perms] Private mode  enable, only admin can publish this module
npm ERR! A complete log of this run can be found in:
npm ERR!      C:\Users\zt\AppData\Roaming\npm_cache\_logs\2019-05-14T07_59_28_430Z-debug.log

cnpm源发布时说我源不正确blog

clipboard.png

因而我又把npm切换回npm,npm源发布时报错token

clipboard.png

意思说必须登陆才能发布包,emmmmm......ip

因而简单粗暴,我去npm.js官网手动注册 https://www.npmjs.com/

手动注册---而后npm login登陆

继续发布 又报错:由于名字重复了(报错:You do not have permission to publish "lx")

$ npm publish
npm notice
npm notice package: lx@1.0.0
npm notice === Tarball Contents ===
npm notice 435B package.json
npm notice === Tarball Details ===
npm notice name:          lx
npm notice version:       1.0.0
npm notice package size:  324 B
npm notice unpacked size: 435 B
npm notice shasum:        60f600a893d64ddc1e71a4707c7de7f5974bcb01
npm notice integrity:     sha512-y16NeHDVs1aLk[...]WU0yjiaIvJD4g==
npm notice total files:   1
npm notice
npm ERR! code E403
npm ERR! 403 Forbidden - PUT https://registry.npmjs.org/lx - You do not have  permission to publish "lx". Are you logged in as the correct user?
npm ERR! A complete log of this run can be found in:
npm ERR!      C:\Users\zt\AppData\Roaming\npm_cache\_logs\2019-05-14T08_29_28_668Z-debug.log
lx名字被占用,改为lx-zt 继续发布,又报错:(you must verify your email before publishing a new package: https://www.npmjs.com/email-edit) 意思是邮箱没有验证

注册以后要去邮箱验证

终于终于终于成功了
有这句话就算成功了:+ lx-zt@1.0.0

clipboard.png

而后我就能够在其余项目安装个人lx-zt,爽

相关文章
相关标签/搜索