尝试让 Gitlab CI 到 运行 NPM 和 Gulp 时出错
Error trying to get Gitlab CI to run NPM and Gulp
NPM 安装正确,但我在部署时一直收到此错误。
npm info ok
$ gulp
/bin/bash: line 48: gulp: command not found
ERROR: Job failed: exit code 1
我的 .gitlab-ci.yml 看起来像这样
image: node:latest
cache:
paths:
- node_modules/
before_script:
- npm install
pages:
stage: deploy
script:
- gulp
artifacts:
paths:
- public
我的package.json包括以下
"scripts": {
"install": "gulp",
"test": "gulp test"
},
"devDependencies": {
"gulp": "^3.9.1"
}
我知道我的 gulpfile.js 很好,因为它在本地运行良好,运行 我需要的一切都在 npm install
或 gulp
上。真的不确定我做错了什么。
通过运行宁npm install
你在本地安装包,它将被保存到项目的node_modules
文件夹中,并且不会全局可用或作为别名(除非它已经全局安装)。因此,如果你想使用 gulp
别名,你应该全局安装它:npm install -g gulp
或者你可以 运行 gulp 来自本地 node_modules
文件夹 ./node_modules/.bin/gulp
命令。
在我添加 -g 标志后它对我不起作用。
为了解决这个问题,我使用了 "export" 指令。
before_script:
- npm install -g grunt grunt-cli
- export PATH=/usr/local/nodejs/node-v7.10.0-linux-x64/lib/node_modules/grunt-cli/bin:$PATH
...
NPM 安装正确,但我在部署时一直收到此错误。
npm info ok
$ gulp
/bin/bash: line 48: gulp: command not found
ERROR: Job failed: exit code 1
我的 .gitlab-ci.yml 看起来像这样
image: node:latest
cache:
paths:
- node_modules/
before_script:
- npm install
pages:
stage: deploy
script:
- gulp
artifacts:
paths:
- public
我的package.json包括以下
"scripts": {
"install": "gulp",
"test": "gulp test"
},
"devDependencies": {
"gulp": "^3.9.1"
}
我知道我的 gulpfile.js 很好,因为它在本地运行良好,运行 我需要的一切都在 npm install
或 gulp
上。真的不确定我做错了什么。
通过运行宁npm install
你在本地安装包,它将被保存到项目的node_modules
文件夹中,并且不会全局可用或作为别名(除非它已经全局安装)。因此,如果你想使用 gulp
别名,你应该全局安装它:npm install -g gulp
或者你可以 运行 gulp 来自本地 node_modules
文件夹 ./node_modules/.bin/gulp
命令。
在我添加 -g 标志后它对我不起作用。 为了解决这个问题,我使用了 "export" 指令。
before_script:
- npm install -g grunt grunt-cli
- export PATH=/usr/local/nodejs/node-v7.10.0-linux-x64/lib/node_modules/grunt-cli/bin:$PATH
...