由于NPM的身份验证问题,服务无法在Kubernetes上运行
我正在尝试将一项服务部署到google cloud kubernetes平台。所有其他服务都正常运行,但由于身份验证错误,此服务无法加载。我不确定是什么问题 这就是错误:由于NPM的身份验证问题,服务无法在Kubernetes上运行,npm,kubernetes,google-cloud-platform,Npm,Kubernetes,Google Cloud Platform,我正在尝试将一项服务部署到google cloud kubernetes平台。所有其他服务都正常运行,但由于身份验证错误,此服务无法加载。我不确定是什么问题 这就是错误: npm ERR! code E401 npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry" 我已经保证了以下几点: .npmrc文件具有正确的注册表 Cloudbuild.yaml存在 Dockerfile在场 该配置与其
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
我已经保证了以下几点:
- .npmrc文件具有正确的注册表
- Cloudbuild.yaml存在
- Dockerfile在场
FROM gcr.io/xxxxx
# Copy in the project files
COPY . .
# Clean
USER root
RUN rm -fr node_modules
USER pptruser
ENV NODE_ENV=production
RUN npm install && \
npm cache clean --force
EXPOSE 4000
# Running the app
CMD [ "npm", "start" ]
“pptruser”并不存在,但在比较了其他服务中的一些DockerFile之后,我意识到它的使用是必不可少的 您能否确保您的
.npmrc
文件以以下格式指向github包注册表:注册表=https://npm.pkg.github.com/
您正在使用GITHUB_令牌?很好的指针-尽管我已经用另一种解决方案解决了这个问题。Github令牌是从Docker基础映像中检索的,因此在那里进行处理。