mia*_*ech 3 publish node.js npm
我已经使用npmjs.com创建了一个帐户,我也正在从命令行(linux)中学习如何操作npm教程.我正处于发布测试模块的阶段.但我一直在收到错误:
You must sign up for private packages : @zentech/node
Run Code Online (Sandbox Code Playgroud)
这些都是npm发布时的错误
npm ERR! publish Failed PUT 402
npm ERR! Linux 4.10.0-33-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "publish"
npm ERR! node v4.7.2
npm ERR! npm v3.5.2
npm ERR! code E402
npm ERR! You must sign up for private packages : @zentech/node
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/george/node/npm-debug.log
Run Code Online (Sandbox Code Playgroud)
我的package.json文件
{
"name": "@zentech/node",
"version": "1.0.1",
"main": "index.js",
"preferGlobal": true,
"scripts": {
"test": "node test.js"
},
"author": "",
"license": "ISC",
"description": "",
"repository": "http://github.com/zentech/node"
}
Run Code Online (Sandbox Code Playgroud)
有谁知道错误的原因?谢谢
Zap*_*ree 14
正如上面的评论中所建议的那样,发布范围包的方式即
@scope/my-package
Run Code Online (Sandbox Code Playgroud)
是在发布时使用--access标志
npm publish --access=public
Run Code Online (Sandbox Code Playgroud)
你并不需要注册为私人包,除非你真的想你的包是私有的.
或者您可以将公共访问权限设置为package.json:
{
...
"publishConfig": {"access": "public"}
...
}
Run Code Online (Sandbox Code Playgroud)
而不是:
{
...
"publishConfig": {"access": "restricted"}
...
}
Run Code Online (Sandbox Code Playgroud)