发布公共范围的包时,可能会收到以下错误
npm ERR! code E402
npm ERR! 402 Payment Required - PUT https://registry.npmjs.org/.... - You must sign up for private packages
尝试发布公共范围的包时会发生这种情况。默认访问级别为私有。要解决此问题,可以设置npm config set access public
或添加以下内容到package.json
{
// ...
// 添加以下
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
// ...
}