Cloud build access to npm repository in artifact registory forbidden

I am building a nodejs application with cloud build. The application depends on an npm package that is hosted on google cloud artifact registry. I have created a cloud build trigger that builds the application. I am getting the following error during the build process:

An unexpected error occurred: “https://us-centeral1-npm.pkg.dev/my-project/my-repo/@my-ui/emoji/-/@my-ui/emoji-0.1.1.tgz: Request failed “403 Forbidden””..

I think the error means it cannot access the repository but that should not be the case since it has the relevant permission. I have a .npmrc file that has the registry in the application as below:

@my-ui:registry=https://us-central1-npm.pkg.dev/my-project/my-repo/
//us-central1-npm.pkg.dev/my-project/my-ui/:always-auth=true

I saw another question here which basically talks about a similar issue I don’t have the .npmrc file in my .gitignore nor .gcloudignore nor .dockerignore file(s).

The cloud build trigger uses the default cloud build service account which I confirmed has artifact registry administrator permission so I assume that should allow it to be able to access the npm package.

Leave a Comment