GitLab private runner stuck on npm install - npm

I'm trying to set up a CI pipeline on GitLab.com using a private runner instead of a shared one. The project uses Node, so I'm using a node:6 image.
The .gitlab-ci.yml looks like this:
image: node:6
stages:
- test
javascript_tests:
stage: test
script:
- npm install
- npm run test:unit
when: always
The runner stays on "running" stage for about 30 minutes and only then started to output something relevant:
npm ERR! fetch failed
http://10.252.156.164:4880/#types%2fjsforce/-/jsforce-1.9.2.tgz
npm WARN retry will retry, error on last attempt: Error: connect ETIMEDOUT 10.252.156.164:4880
What can I do to solve this? I thought that installing gitlab-runner on a DigitalOcean droplet would be the only things to worry about.

Replacing node:6 with node:latest fixed this problem.

Related

Self-hosted GitLab Runner with shell executor can’t find npm

I’m configuring a very simple CI job. GitLab Runner is running on my own server, the specific runner for this project has been registered, with the shell executor, as I want to simply run shell commands.
stages:
- build
build:
stage: build
script:
- npm install
- npm run build
artifacts:
paths:
- "public/dist/main.js"
only:
- master
The job fails at the first command, npm install, with npm: command not found. I just installed npm and node via npm. If I SSH on my server and run npm -v, I can see version 8.5.5 is installed. If I sudo su gitlab-runner, which I suppose is what GitLab Runner is running as, npm -v works just as well.
I installed npm while gitlab-runner was already running. So I ran service gitlab-runner restart, thinking that it had to reevaluate its PATH, but it didn’t fix the issue.
I fixed it by simply adding this command before npm install: . ~/.bashrc.
I’m not sure why gitlab-runner didn’t properly read .bashrc before, even though I restarted it. Maybe it’s not supposed to? That would be contrary to what’s said in the GitLab CI runners docs.
N.B.: A key element in me being able to debug this was to clone the repo on a folder on my server, cd into it, and run gitlab-runner exec shell build after any (local) change to .gitlab-ci.yml. Skipping the whole commit + push + wait was a huge time (and sanity) saver.

NPX command not running in Azure pipeline

I need your help
I was trying to run my cypress test cases which I generally run using command
"npx cypress run"
so I tried to have the same command in tasks when I created Azure pipeline
after NPM Install
I even tried installing npx via
npm task and custom command "npm install nx"
and this causing the below issue so can anyone suggest to me how to proceed in this case
"##[warning]Couldn't find a debug log in the cache or working directory
##[error]Error: Npm failed with return code: 1
"
From the error screenshot, it shows that you are using the Npm Task and running the command: npm npm install nx.
The command is invalid.
To solve this issue, you need to remove the npm in the NPM task -> Command and arguments .
Refer to the following sample:
YAML Pipeline:
- task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'install nx'
Classic Pipeline:

How can I set the npm version in gitlab CI?

I have a gitlab pipeline for an Angular project with the image in .gitlab-ci.yml
image: node:16
build:
stage: build
script:
- npm ci
- nodejs -v
- npm -v
- npm run build:prod
- npm doctor
When the pipeline reaches the npm doctor it fails with the following error on npm version:
$ npm doctor
Check Value Recommendation/Notes
npm ping ok
npm -v not ok Use npm v7.24.0
node -v ok current: v16.9.1, recommended: v16.9.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
which git ok /usr/bin/git
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
Perms check on global bin folder ok
Verify cache contents ok verified 1361 tarballs
How can I solve this?
In my machine I have the npm version v7.24.0 and the command succeeds.
Install npm before you do anything else, specifying a version, i.e. npm install npm#version -g.
For completeness, if you can't update the global npm, you can do so locally, by replacing npm with npx npm#latest or npx npm#7.24.0. npx will install npm if it needs to, locally, and then run the local installation.
Lastly you can install locally with npm install npm#latest and then run it with $(npm bin)/npm, but this is what npx is for.
Note that I don't understand why you're running npm doctor after a build. Presumably if you care about npm thining it's set up properly you should run it before the build, so the pipeline fails early.
P.S. I stupidly read 'github' as 'gitlab'. If you were using github I would recommend using
setup-node if only for dependency caching, which can seriously speed up pipelines. I don't know if gitlab does anything similar.

How to ignore npm run errors and keep going on Travis-CI?

I have stage in Travis config that launch npm run build where the build is a script converting ts -> js. Locally, it returns two errors that doesn't matter anything, I can run a server anyway. But, these errors stop Travis moving on and fails.
- stage: "Build front"
before_script:
- cd front
- npm install
- npm run build
The error:
...
[0] npm run build:client exited with code 0
build/setupProdServer.ts(6,20): error TS2307: Cannot find module '../src/vue-ssr-server-bundle.json'.
build/setupProdServer.ts(7,28): error TS2307: Cannot find module '../src/vue-ssr-client-manifest.json'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
...
I tried add
allow-failures:
- node
- npm
and it not helped.
I need Travis ignore these errors and move to the next stage.
What kind of commands or parameters in Travis will solve it?
Just add || true:
- npm run build || true

NPM not installing devDependencies on bitbucket pipeline?

I'm trying to setup my first Bitbucket pipeline which simply builds my application and deploys it to my FTP server using the following bitbucket-pipelines.yml
image: node:6.9.4
pipelines:
default:
- step:
caches:
- node
script:
- npm install
- npm test
- step:
script:
- npm run build
- node deploy.js
The issue lies in the npm install because when bitbucket tries to run the npm run build command it says that rimraf (a npm package) is not found. rimraf however is listed in my devDependencies, all regular dependencies in my package.json are downloaded correctly.
There is no global variable set by my so the NODE_ENV could not be it right?
I had the same issue with gulp.
Gulp was in devDependencies and also specified in package.json as script but still it said npm ERR! missing script: gulp
The documentation says to install it globally, so there might be a related issue with your package.
https://confluence.atlassian.com/bitbucket/javascript-node-js-with-bitbucket-pipelines-873891287.html
I had this same issue. For me, the problem was that the version of Node on my local development device was different from the version of Node in the bitbucket-pipelines.yml file.
To fix it, I went into bitbucket-pipelines.yml and changed this line:
image: node:10.15.3
to this:
image: node:14.15.0