當執行npm publish 時,出現unauthorized 和 is not in the npm registry


當執行npm publish,發生了如下錯誤:

  1.  
    appledeMacBook-Pro:nini-react apple$ npm publish
  2.  
    npm ERR! publish Failed PUT 401
  3.  
    npm ERR! code E401
  4.  
    npm ERR! 404 unauthorized Login first: nini-react
  5.  
    npm ERR! 404
  6.  
    npm ERR! 404 'nini-react' is not in the npm registry.
  7.  
    npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
  8.  
    npm ERR! 404
  9.  
    npm ERR! 404 Note that you can also install from a
  10.  
    npm ERR! 404 tarball, folder, http url, or git url.
  11.  
     
  12.  
    npm ERR! A complete log of this run can be found in:
  13.  
    npm ERR! /Users/apple/.npm/_logs/2018-02-04T00_32_35_475Z-debug.log
  14.  
    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 的方式;

                                                    

 

 

                但是使用第二種方式可能注冊不一定成功,那么在后續上傳個人的模塊的時候就會出現如下錯誤:

 

 

也就是說,你需要重新注冊才可以;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM