我想将git存储库发布到npm,以便可以在其他项目中使用它。但是,当我运行npm publish
命令时,出现以下错误:
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/vue-toggle-component
npm ERR! 404
npm ERR! 404 '[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\niels\AppData\Roaming\npm-cache\_logs\2020-10-29T10_47_26_952Z-debug.log
尝试进行错误修复时,我尝试了该npm adduser
命令和该npm login
命令以确保我已登录。这两种方法都无法解决我的问题,因为看起来好像我已经登录了。
我的package.json
:
{
"name": "vue-toggle-component",
"version": "0.1.0",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"description": "## Project setup ``` yarn install ```",
"main": "babel.config.js",
"repository": {
"type": "git",
"url": "git+https://github.com/nehlis/vue-toggle-component.git"
},
"keywords": [
"Vue.js",
"Toggle",
"component",
"Lightweight",
"Checkbox"
],
"author": "Niels Bosman",
"license": "ISC",
"bugs": {
"url": "https://github.com/nehlis/vue-toggle-component/issues"
},
"homepage": "https://github.com/nehlis/vue-toggle-component#readme"
}
有谁知道如何解决这一问题?
根据https://npm.pkg.github.com/
错误输出中的显示,您尝试发布到GitHub软件包,而不是npm注册表(尽管GitHub现在拥有npm,它们仍是单独的)。根据GitHub软件包docs:
GitHub软件包仅支持作用域npm软件包。作用域软件包的名称格式为@ owner / name。范围包始终以@符号开头。您可能需要更新package.json中的名称以使用范围名称。例如,“名称”:“ @ codertocat / hello-world-npm”。
因此,您需要更改配置以指向npm注册表,而不是GitHub软件包注册表,或者将name
您的字段更改package.json
为有范围的软件包名称。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句