我在 package.json 文件中的 scripts
> preinstall
或者 scripts
> prepare
中运行了这个命令:
aws codeartifact login --tool npm --repository my-repo --domain my-domain --domain-owner <123456789> --profile <me>
完整文件:(<123456789>
和 <me>
已修改为stackoverflow)
{
"name": "my-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"preinstall": "npm run co:login",
"co:login": "aws codeartifact login --tool npm --repository my-repo --domain my-domain --domain-owner <123456789> --profile <me>",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"uuid": "^3.3.2",
"@my-npm/my-common": "1.0.0"
}
}
在运行aws codeartifact login ..
命令之前,我的.npmrc
文件如下:
registry=https://registry.npmjs.org
@my-npm:registry=https://my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/-repo/
我的 .npmrc
文件已修改:
registry=https://my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/-repo/
@my-npm:registry=https://my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/-repo/
//my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/my-repo/:always-auth=true
//my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/my-repo/:_authToken=eyJ2ZXIiOjEsIml....
但我需要保留这个:
registry=https://registry.npmjs.org
@my-npm:registry=https://my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/-repo/
//my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/my-repo/:always-auth=true
//my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/my-repo/:_authToken=eyJ2ZXIiOjEsIml....
@my-npm
,则默认注册表不受影响。 - Stéphane GRILLON