I am always getting an error on npm install after setting NPM Authenticate. I would like to authenticate to my npm private registry during image build and install all the dependencies I need. Maybe I misunderstood how this authentication process works but this is what I am doing:
Build pipeline
I tried establishing a service connection from the project settings page as in Service connections for builds and releases
After that, I also set up my NPM Authentication task following the steps in With a Task Runner (e.g. make gulp work)
But this is not working. These are the errors I am getting:
During 'NPM Authenticate' phase:
[warning]Found and overrode credentials for the myregistry.pkgs.visualstudio.com registry in the selected .npmrc file. Remove credentials from the file and store them in an npm service connection instead (recommended), or remove the npm Authenticate task from your build to use credentials checked into an .npmrc.
During 'Build an Image' phase:
Step 4/7 : RUN npm install --production ---> Running in 8724f713f1db [91mnpm ERR! code[0m[91m E404 [0m[91mnpm [0m[91mERR! 404[0m[91m Not Found: @myregistry/service-logging@latest npm ERR![0m[91m A complete log of this run can be found in: npm ERR!
/root/.npm/_logs/2018-09-11T04_20_00_513Z-debug.log [0mThe command '/bin/sh -c npm install --production' returned a non-zero code: 1 [error]The command '/bin/sh -c npm install --production' returned a non-zero code: 1 [error]/usr/local/bin/docker failed with return code: 1 [section]Finishing: Build an image
This is my .npmrc file:
unsafe-perm=true
package-lock=false
registry=https://myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/
always-auth=true
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/registry/:_authToken=${NPM_TOKEN}
//myregistry.pkgs.visualstudio.com/_packaging/myregistry/npm/:_authToken=${NPM_TOKEN}
And this is my Dockerfile:
FROM node:8.9-alpine
ARG NPM_TOKEN
WORKDIR /usr/src/srv/
COPY package.json package.json
COPY .npmrc .npmrc
RUN npm install --production
RUN rm -f .npmrc
COPY . .
EXPOSE 8080
CMD npm start
Any help to unblock me from this issue will be highly appreciated! Thanks!