3 Possible reasons could be:
- You've cached the version of the package, npm using the cached version while you run
npm i
, you can clear the cache data using the below command.
npm cache clean --force
- Expired codeartifact credentials, you can update them using the below command.
CODEARTIFACT_DOMAIN=<your codeartifact domain>
CODEARTIFACT_REPO=<your codeartifact repo>
NAMESPACE=<your package namespace>
# Get AWS account ID
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text)
# Get CodeArtifact authorization token and endpoint
CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain $CODEARTIFACT_DOMAIN --query authorizationToken --output text)
CODEARTIFACT_ENDPOINT=$(aws codeartifact get-repository-endpoint --domain $CODEARTIFACT_DOMAIN --repository $CODEARTIFACT_REPO --format npm)
# Set default registry back to npmjs.org
npm config set registry=https://registry.npmjs.org
# Set authentication token and always-auth option for CodeArtifact repository
npm config set //$CODEARTIFACT_DOMAIN-$AWS_ACCOUNT_ID.d.codeartifact.ap-south-1.amazonaws.com/npm/$CODEARTIFACT_REPO/:_authToken=$CODEARTIFACT_AUTH_TOKEN
npm config set //$CODEARTIFACT_DOMAIN-$AWS_ACCOUNT_ID.d.codeartifact.ap-south-1.amazonaws.com/npm/$CODEARTIFACT_REPO/:always-auth=true
# Namespace-specific config
npm config set @$NAMESPACE:registry https://$CODEARTIFACT_DOMAIN-$AWS_ACCOUNT_ID.d.codeartifact.ap-south-1.amazonaws.com/npm/$CODEARTIFACT_REPO/
- Improper
yarn.lock
, this might contain the resolved URL with the expired auth token, you can remove the yarn.lock
and regenerate it by running yarn
And if you're using yarn v2, then look into this answer