Problem to solve
I’m trying to get Gitlab CI/CD to install NPM packages from a private gitlab package repository. NPM however seems to ignore all user settings and still tries to get the package from the public npm registry. The config seems to be set correctly. On my local device the same steps work fine.
Why does NPM ignore the user settings and still use the public repository?
npm http fetch GET 404 https://registry.npmjs.org/@slimm/chartjs-plugin-threshold 476ms (cache skip)
Configuration
image: node:latest
stages:
- deploy
before_script:
- npm cache clean --force
- echo "registry=https://gitlab.com/api/v4/packages/npm/" > .npmrc
- echo "//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
- npm config get registry
- npm install @slimm/chartjs-plugin-threshold --verbose
publish-npm:
stage: deploy
script:
- npm run build
CI/CD output
$ npm cache clean --force
npm warn using --force Recommended protections disabled.
$ echo "registry=https://gitlab.com/api/v4/packages/npm/" > .npmrc
$ echo "//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
$ npm config get registry
https://gitlab.com/api/v4/packages/npm/
$ npm install @slimm/chartjs-plugin-threshold --verbose
npm verbose cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@10.8.2
npm info using node@v22.8.0
npm verbose title npm install @slimm/chartjs-plugin-threshold
npm verbose argv "install" "@slimm/chartjs-plugin-threshold" "--loglevel" "verbose"
npm verbose logfile logs-max:10 dir:/root/.npm/_logs/2024-09-10T10_57_03_464Z-
npm verbose logfile /root/.npm/_logs/2024-09-10T10_57_03_464Z-debug-0.log
npm http fetch GET 404 https://registry.npmjs.org/@slimm/chartjs-plugin-threshold 476ms (cache skip)
npm verbose stack HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/@slimm/chartjs-plugin-threshold - Not found
npm verbose stack at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verbose stack at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
npm verbose stack at async RegistryFetcher.packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/registry.js:90:19)
npm verbose stack at async RegistryFetcher.manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/registry.js:128:23)
npm verbose stack at async #fetchManifest (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1199:20)
npm verbose stack at async #nodeFromEdge (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1037:19)
npm verbose stack at async #buildDepStep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:901:11)
npm verbose stack at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:181:7)
npm verbose stack at async Promise.all (index 1)
npm verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
npm verbose statusCode 404
npm verbose pkgid @slimm/chartjs-plugin-threshold@*
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@slimm/chartjs-plugin-threshold - Not found
npm error 404
npm error 404 '@slimm/chartjs-plugin-threshold@*' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.