NPM发布错误:您需要使用npm adduser对此计算机进行授权

3ks5zfa0  于 2023-03-03  发布在  其他
关注(0)|答案(2)|浏览(247)

我尝试在升级到node v18npm v9后在软件包上运行npm publish
但我得到了以下错误:

您需要使用npm adduser * 授权此计算机
我的用户.npmrc文件:

//some-package.com:48082/nexus/repository/:keyfile=/Users/<host>/Documents/Certificates/npm.key.pem.   
//some-package.com:48082/nexus/repository/:certfile=/Users/<host>/Documents/Certificates/npm.crt.pem
//registry.npmjs.org/:_authToken=<auth_token>

我的项目.npmrc文件:

@fortawesome:registry=https://npm.fontawesome.com/.  
 @scope1:registry=https://some-package.com:48082/nexus/repository/path1/   
 @scope2:registry=https://some-package.com:48082/nexus/repository/path2/  
 //npm.fontawesome.com/:_authToken=<auth_token>   
 //some-package.com:48082/nexus/repository/:_auth=<auth>   
 strict-ssl=false
6ss1mwsb

6ss1mwsb1#

要将软件包发布到NPM,您需要登录到NPM注册表。以下是几个步骤-

登录NPM

  • 如果您未注册
npm adduser
  • 如果您已经注册
npm login
  • 如果您已登录并要验证用户
npm whoami

构建和发布

  • 创建生成
npm run build-library
  • 发布到NPM
npm publish --access public
nx7onnlm

nx7onnlm2#

此问题的修复方法是,我们需要在存储库级别(而不是nexus级别)的global .npmrc中添加证书和密钥文件:

//some-package.com:48082/nexus/repository/path1/:keyfile=/Users/<host>/Documents/Certificates/npm.key.pem   
//some-package.com:48082/nexus/repository/path1/:certfile=/Users/<host>/Documents/Certificates/npm.crt.pem
//some-package.com:48082/nexus/repository/path2/:keyfile=/Users/<host>/Documents/Certificates/npm.key.pem   
//some-package.com:48082/nexus/repository/path2/:certfile=/Users/<host>/Documents/Certificates/npm.crt.pem

对于project .npmrc也是如此:

//some-package.com:48082/nexus/repository/path1/:_auth=<auth>                        
//some-package.com:48082/nexus/repository/path2/:_auth=<auth>

相关问题