當執行npm publish,發生了如下錯誤:
-
appledeMacBook-Pro:nini-react apple$ npm publish
-
npm ERR! publish Failed PUT 401
-
npm ERR! code E401
-
npm ERR! 404 unauthorized Login first: nini-react
-
npm ERR! 404
-
npm ERR! 404 'nini-react' 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 ERR! A complete log of this run can be found in:
-
npm ERR! /Users/apple/.npm/_logs/2018-02-04T00_32_35_475Z-debug.log
-
appledeMacBook-Pro:nini-react apple$
起先以為是賬戶的問題,我就執行了npm adduser 和 npm login 都不行。
您首先執行下 npm adduser
,輸入您相應的 Username
、 Password
、 Email: (this IS public)
,關鍵的一步來了!
Logged in as 您的Username on https://registry.npmjs.org/.
如果 on
后面不是 https://registry.npmjs.org/
,而是其他的鏡像,比如我們大家常見的淘寶鏡像:
http://registry.npm.taobao.org/
那么您首先替換成原來的,替換成原來執行如下命令:
npm config set registry https://registry.npmjs.org/
最后,替換完畢再執行 npm adduser
、 npm publish
,這樣應該就ok了!
看下是不是你配置了源,比如為了加速使用了淘寶的鏡像
如果使用了淘寶鏡像,先還原淘寶鏡像
1.使用 cnpm 的注意報錯:
no_perms Private mode enable, only admin can publish this module
設置回原本的就可以了:
npm config set registry http://registry.npmjs.org
2.npm包package.json中registory屬性一定要填寫,每次publish npm時package.json中version版本一定要大於上一次。
3.npm publish failed put 500 unexpected status code 401這樣的報錯信息,往往是沒有登錄成功,操作npm login
在使用npm的時候,免不了要注冊一個用戶
注冊用戶有兩種方式: 第一種是進入官網界面進行注冊:點擊進入官網
第二種是:使用 npm adduser 的方式;
但是使用第二種方式可能注冊不一定成功,那么在后續上傳個人的模塊的時候就會出現如下錯誤:
也就是說,你需要重新注冊才可以;