在gitlabpipe道中安装private npm包
如果需要使用npm安装私有存储库, NPM_TOKEN
需要设置环境variablesNPM_TOKEN
。
NPM_TOKEN=00000000-0000-0000-0000-000000000000
我在gitlabpipe道中的构build阶段需要安装一个私有存储库。 因此,我把这个NPM_TOKEN
秘密variables放在我的gitlab pipeline
设置中。
我目前的gitlab-ciconfiguration:
image: x/node build_job: script: - printenv NPM_TOKEN - npm i @x/test
docker图像是我只是设置一个.npmrc
文件:
FROM node:latest COPY .npmrc .
我在同一个目录中有.npmrc
:
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
我已经尝试了docker形象:
run -it myimage bash export NPM_TOKEN=... npm i @x/test
这工作,私人包安装。
但是,在gitlabpipe道上,它找不到包(404)。 当作业运行时,我可以清楚地看到正在打印的NPM_TOKEN
envvariables。 所以我不知道发生了什么事
我把gitlab-ci改成这样:
image: dasnoo/node build_job: script: - printenv NPM_TOKEN - npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - npm i @dasnoo/testpriv
它的工作。 不过为什么我不得不这样做