在Gitlab ci中使用NPM发布节点模块不会';行不通

在Gitlab ci中使用NPM发布节点模块不会';行不通,npm,gitlab-ci-runner,npm-publish,Npm,Gitlab Ci Runner,Npm Publish,我正在使用gitlab ci为我的ci/CD将NPM模块发布到注册表。下面是我的gitlab-ci.yml文件 image: docker:latest variables: DOCKER_DRIVER: overlay2 services: - docker:dind cache: untracked: true key: "$CI_COMMIT_REF_NAME" paths: - node_modules/ stages: - setup job-s

我正在使用gitlab ci为我的ci/CD将NPM模块发布到注册表。下面是我的gitlab-ci.yml文件

image: docker:latest

variables:
  DOCKER_DRIVER: overlay2

services:
- docker:dind

cache:
  untracked: true
  key: "$CI_COMMIT_REF_NAME"
  paths:
    - node_modules/
stages:
    - setup

job-setup:
   stage: setup
   tags:
    - angular
   image: node:alpine
   except: 
    - tags
   script:
     - npm set registry https://registry.npmjs.org
     - npm i
     - cp .npmrc ~/.npmrc
     - npm publish --registry https://registry.npmjs.org
我在publish命令上收到以下警告消息。模块已发布,但模块中的/dist文件夹丢失

npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.
npm WARN lifecycle my_npm_module@1.1.1~prepublish: cannot run in wd %s %s (wd=%s) my_npm_module@1.1.1 npm run build /builds/code/my_npm_module
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

NPM在“工作目录”(wd)中运行时遇到问题,我不知道如何解决。我正在Centos上运行gitlab ci。

npm
拒绝从您的
package.json
运行构建脚本,因为它是以root用户身份运行的。加

echo "unsafe-perm = true" >> ~/.npmrc

在调用
npm

npm
之前,您的
gitlab ci.yml
脚本拒绝从您的
package.json
运行构建脚本,因为它是以根用户身份运行的。加

echo "unsafe-perm = true" >> ~/.npmrc

在调用
npm

之前,将其添加到您的
gitlab ci.yml
脚本中,这解决了我的问题。我不知道gitlab运行程序正在以root用户身份执行这些命令,并且错误消息没有帮助:
~prepublish:cannotruninwd%s%s(wd=%s)
这解决了我的问题。我不知道gitlab运行程序正在以root用户身份执行这些命令,并且错误消息没有帮助:
~prepublish:cannotruninwd%s%s(wd=%s)