I run this commande in a package.json file (scripts
> preinstall
) or (scripts
> prepare
):
aws codeartifact login --tool npm --repository my-repo --domain my-domain --domain-owner <123456789> --profile <me>
full file: (<123456789>
and <me>
is modified for 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"
}
}
My .npmrc
file before aws codeartifact login ..
commande:
registry=https://registry.npmjs.org
@my-npm:registry=https://my-domain-<123456789>.d.codeartifact.eu-west-1.amazonaws.com/npm/-repo/
My .npmrc
file is modified:
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....
but I need keep this:
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....
Open your ~/.npmrc
and ensure that the first line is:
registry=https://registry.npmjs.org
Then update the original co:login
package command to include --namespace @my-npm
at the end of command. When you next run co:login
you'll be authed and the ~/.npmrc
will be updated with the correct namespaced repository and also include the public npm repository on the first line.
The parameter added changes only the scope @my-npm:registry=...
in the .npmrc
file.