我正在尝试使用
当我在本地执行发布脚本时,在脚本第一次运行时出现了以下错误:
npm publish
将javascript库发布到托管在AWS Codeartifact上的私有NPM存储库。当我在本地计算机上运行npm publish
时,它可以正常工作。然而,当我在Jenkins上运行时,似乎该软件包尝试发布到NPM的软件包存储库,而不是AWS Codeartifact,并且我会收到以下错误: > @company/package@0.2.2 prepare .
> npm run co:login
> @company/package@0.2.2 co:login /usr/src/components
> aws codeartifact login --tool npm --domain <DOMAIN> --repository <REPOSITORY>
Successfully configured npm to use AWS CodeArtifact repository <AWS_CODEARTIFACT_URL>
Login expires in 12 hours at 2020-12-08 11:15:37+00:00
npm notice
npm notice package: @company/package@0.2.2
npm notice === Tarball Contents ===
npm notice 2.9kB package.json
npm notice 1.6kB README.md
npm notice 268B dist/index.d.ts
npm notice === Tarball Details ===
npm notice name: @company/package
npm notice version: 0.2.2
npm notice package size: 2.1 kB
npm notice unpacked size: 4.8 kB
npm notice shasum: <SHASUM>
npm notice integrity: <INTEGRITY>
npm notice total files: 3
npm notice
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@company%2fpackage - Not found
npm ERR! 404
npm ERR! 404 '@company/package@0.2.3' 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! /root/.npm/_logs/2020-12-08T00_20_19_949Z-debug.log
如果我理解AWS codeartifact文档正确的话,当我们运行aws codeartifact login
命令时,它应该在.npmrc
中设置正确的设置。我仍然不明白为什么它试图将内容推送到npm注册表而不是AWS。
以下是我的package.json文件:
{
"name": "@company/package",
"version": <VERSION>,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"dependencies": {...},
"scripts": {
"co:login": "aws codeartifact login --tool npm --domain <DOMAIN> --repository <REPOSITORY>",
"prepare": "npm run co:login"
},
"eslintConfig": {...},
"browserslist": {...},
"peerDependencies": {...},
"devDependencies": {...}
}
更新
我添加了使用 CodeArtificat 的链接。
npm set registry <LINK_TO_CODE_ARTIFACT>
当我在本地执行发布脚本时,在脚本第一次运行时出现了以下错误:
Unable to authenticate, need: Bearer realm="company/package", Basic realm="company/package"
那个错误在后续运行中消失了。然而,当我在我的 Jenkins 管道上尝试相同的操作时,我不断地遇到这个错误。不确定这是什么意思。我看到了一个与 Azure 相关的讨论线程,但无法在 AWS CodeArtifact 上找到任何信息。