【发布时间】:2022-01-09 18:00:05
【问题描述】:
我正在尝试将演示按钮组件发布到 npm 并遵循此tutorial
我的 package.json
{
"types": "dist/index.d.ts",
"files": [
"dist"
],
"publishConfig": {
"registry": "https://npm.pkg.github.com/abhinav-anshul"
},
"name": "@abhinav-anshul/avyav",
"version": "1.0.5",
"description": "",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"scripts": {
"rollup": "rollup -c"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.0",
"@types/react": "^17.0.38",
"react": "^17.0.2",
"rollup": "^2.63.0",
"rollup-plugin-dts": "^4.1.0",
"typescript": "^4.5.4"
}
}
我的 .npmrc :
always-auth = true
registry=https://registry.npmjs.org/
@abhinav-anshul:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=<TOKEN CREATED USING GITHUB>
我的 Github repo 用于相同的here
我面临的问题是:
-
我已经添加了一个token并发布为“github包”,我可以看到它成功发布在我的终端上,在github包上也是如此,在repo下,它指示我做
npm install @abhinav-anshul/avyav@1.0.5 -
但是,当我尝试完全安装在不同的项目中时,我收到的错误消息是
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@abhinav-anshul%2favyav - Not found
npm ERR! 404
npm ERR! 404 '@abhinav-anshul/avyav@1.0.5' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
- 另外,我在 npmjs.org 网站上搜索包也找不到。
我不确定的事情:
- 是因为我的token吗?
- 如果某个东西作为 github 包发布,并且它确实指示我使用 npm 安装它,那么为什么它在 npmjs 站点上不可用?这是两个不同的东西吗?
任何正确方向的输入都会很有帮助。 我是第一次尝试发布一个包,如果我错过了任何明显的东西,很抱歉。
感谢您的阅读。
【问题讨论】:
-
按照该视频教程后我面临同样的问题
-
我确实设法修复了它,您需要将 package.json 更改为
"repository": { "type": "git", "url": "git://github.com/abhinav-anshul/avyav.git" }, -
@VikrantBhat 参考这个 repo(检查 package.json 文件)-> github.com/abhinav-anshul/avyav ,我也向 npm 发布了同样的内容
标签: node.js npm package.json github-package-registry