Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
由于NPM的身份验证问题,服务无法在Kubernetes上运行_Npm_Kubernetes_Google Cloud Platform - Fatal编程技术网

由于NPM的身份验证问题,服务无法在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在场 该配置与其

我正在尝试将一项服务部署到google cloud kubernetes平台。所有其他服务都正常运行,但由于身份验证错误,此服务无法加载。我不确定是什么问题

这就是错误:

npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
我已经保证了以下几点:

  • .npmrc文件具有正确的注册表
  • Cloudbuild.yaml存在

  • Dockerfile在场

该配置与其他正常工作的服务几乎相同

编辑:此外,还有一个与此生成关联的身份验证令牌,它来自dockerfile中链接的基本Docker映像

修复了这个问题:

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基础映像中检索的,因此在那里进行处理。