我试图在npm上发布一个公共包,但是出现了这个错误:
npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/@clem_b%2fweather - Forbidden
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
所以首先观察我的package.json
如下。
{
"name": "@clem_b/weather",
"version": "1.0.6",
"description": "weather cli",
"main": "build/main.js",
"types": "build/main.d.ts",
"homepage": "https://github.com/ClementBolin/weatherCLI#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ClementBolin/weatherCLI.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rimraf ./build && tsc",
"start": "npm run build && node build/mai.js"
},
"bin": {
"app": "bin/weatherCLI"
},
"keywords": [
"weather",
"today",
"rain",
"sun"
],
"author": "clem_b",
"license": "MIT",
"devDependencies": {
"@types/minimist": "^1.2.0",
"@types/node": "^14.14.6",
"@types/oauth": "^0.9.1",
"@types/ora": "^3.2.0",
"rimraf": "^3.0.2",
"tslint": "^6.1.3",
"typescript": "^4.0.5"
},
"prepublish": "npm run build",
"dependencies": {
"minimist": "^1.2.5",
"oauth": "^0.9.15",
"ora": "^0.3.0"
}
}
写完代码后,我决定在npm上发布我的代码,因此我创建了npm账户,并使用npm login
连接到我的账户。之后,我运行以下命令npm publish --access public
,但是出现了一个错误。我查询了很多主题,但是没有找到解决方案。