Reputation: 2708
I have been playing around Gitlabl CI but for some reason I can't get my tests to "passed". It always says npm: command not found
My Gitlab CI config looks like this:
image: node:latest
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- node_modules/
before_script:
- npm install
- npm install eslint -g
- npm install eslint-plugin-react -g
- npm install babel-eslint -g
test:lint:
script:
- eslint src/*
I keep getting the error below and I have No Idea why:
By the way, Im NOT using the gitlab shared runner. Not sure if that contributes to the problem but just to make sure, the machine that has my gitlab runner has all the necessary packages to run nodejs.
Your help is greatly appreciated
Best regards,
Upvotes: 16
Views: 32521
Reputation: 93
This worked greatly for me
before_script:
- apt-get update -qy
- apt-get install --no-install-recommends -y npm
- npm --version
- npx --version
- gem install dpl
- npm install
Source: https://forum.gitlab.com/t/bin-bash-line-131-npm-command-not-found/70632/3
Upvotes: 0
Reputation: 1
If you are using sshpass to pass some command to your server, you'll have to update your .bashrc file (file path: ~/.bashrc).
In .bashrc file you see following code uncommented, comment it and it resolve your issue.
case $- in
*i*) ;;
*) return;;
esac
Upvotes: 0
Reputation: 109
In my case, there are two gitlab-runner. There is no node enviroment in the specific Runner.Then I stopped the wrong one
Upvotes: -1
Reputation: 229
You can use like below:-
stages:
- build
- deploy
deploy-prod:
image: node:12.13.0-alpine
stage: deploy
script:
- npm i -g firebase-tools
Upvotes: 2
Reputation: 311
Your cli is taking ssh executer by default. You probably need docker. Try adding tag in your yml script.
tags: [ <your docker image name> ]
Upvotes: 0
Reputation: 11
This helped me:
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
Upvotes: 0
Reputation: 1
I have same problem.
Gitlab-runner use user of 'gitlab-runner' default when it starts. So the user have not root access.
ps aux|grep gitlab-runner
copy the shell of running
change user:
run /usr/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user root
in bash.
gitlab-ci runner test
pass!
kill old pid
nohup /usr/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user root
ps: gitlab-runner -u root
also change user.
Upvotes: 0
Reputation: 807
The image
tag specifies a docker image, hence you must specify the executor of your runner to be docker
. Did you perhaps set it to be something else, like shell
, when you created the runner?
Upvotes: 8