npm发布失败的PUT 402

Jos*_*man 39 npm

正在学习让我参加Bash教程的课程.到目前为止,我被困在代码要求我发布代码的部分.我的说明如下:

 What good is a package manager without packages?  

 Not very good.  

 Luckily, that is not a problem for npm, because it's very easy for all  
 npm users to publish their modules and share them with the world.  

 Packages get into the registry by using the `npm publish` command.  

 Try it now. There's not much to it.  

 (Make sure you're still in the right project directory, though.  If you  
 publish something by mistake, you can remove it, but there's no guarantee  
 that no one saw it in the meantime.)  

 Then run `how-to-npm verify` when you're done.
Run Code Online (Sandbox Code Playgroud)

我的代码是:

jsf2008:~/workspace/dev (master) $ npm publish
npm ERR! publish Failed PUT 402
npm ERR! code E402
npm ERR! You must sign up for private packages : @jsf2008/quit
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2017-08-22T14_44_29_746Z-debug.log
jsf2008:~/workspace/dev (master) $ 
Run Code Online (Sandbox Code Playgroud)

我在这里很迷茫.我甚至无法在任何地方找到Error PUT 402.任何帮助将不胜感激.

Ale*_*ack 83

您正在使用NPM Scoped软件包.默认情况下,它们是私有的,需要为私人帐户支付NPM.如果您的包是公共的,您可以使用这样的--access=public标志:

npm publish --access=public
Run Code Online (Sandbox Code Playgroud)

  • $ npm publish --access = public npm ERR!发布失败的PUT 404 npm ERR!代码E404 npm ERR!找不到404范围:@ logcat-org/web-log npm ERR!404 npm ERR!404'@ logcat-org/web-log'不在npm注册表中.错误的ERR!404你应该告诉作者发布它(或者自己使用这个名字!)npm ERR!404 npm ERR!404请注意,您也可以从npm ERR安装!404 tarball,文件夹,http url或git url.错误的ERR!可以在以下位置找到此运行的完整日志:npm ERR!/Users/a/.npm/_logs/2017-09-17T04_05_55_360Z-debug.log (3认同)

Ben*_*uer 19

您可以通过将以下内容添加到package.json文件中来解决该问题:

包.json

"publishConfig": {
  "access": "public"
}
Run Code Online (Sandbox Code Playgroud)

publishConfig管理包的可见性。如果您定义“公共”访问权限,那么每个人都可以从 npm 注册表下载您的包。

如果您定义“受限”访问,则包的使用者必须将.npmrc文件添加到自己的包中才能设置访问令牌:

.npmrc

always-auth=true
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
Run Code Online (Sandbox Code Playgroud)

注意:.npmrc使用“公共”访问权限时不需要该文件。


Dom*_*nic 5

首先创建组织:https//www.npmjs.com/org/create

然后跑 npm publish --access public