'Gitlab CI Build issue
I have the following pipeline:
stages: # List of stages for jobs, and their order of execution
- pre-build
- build
- build-image
- lint
- test
- deploy
- post-deploy
pre-build-job:
stage: pre-build
image: node:latest
script: npm install
When my pipeline run I am getting the following error
Running with gitlab-runner 14.10.0~beta.50.g1f2fe53e (1f2fe53e)
on blue-2.shared.runners-manager.gitlab.com/default XxUrkriX
Preparing the "docker+machine" executor
00:31
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:b6c4441a8ff54a943185c37bdca51cc45304d3b22e985dcc3bf7b5e1d680f7ea for node:latest with digest node@sha256:82f9e078898dce32c7bf3232049715f1b8fbf0d62d5f3091bca20fcaede50bf0 ...
Preparing environment
00:03
Running on runner-xxurkrix-project-17041112-concurrent-0 via runner-xxurkrix-shared-1652891281-7b8723e4...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/*****/.git/
Created fresh repository.
Checking out a61c9061 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:b6c4441a8ff54a943185c37bdca51cc45304d3b22e985dcc3bf7b5e1d680f7ea for node:latest with digest node@sha256:82f9e078898dce32c7bf3232049715f1b8fbf0d62d5f3091bca20fcaede50bf0 ...
$ npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /builds/****/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/builds/****/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-18T16_29_25_203Z-debug-0.log
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
what do I need to do? I am confused.
Thanks
Solution 1:[1]
When the runner runs it pulls the repository to a folder called "/builds" and does its job from there.
Initialized empty Git repository in /builds/*****/.git/
So once it started with the first command: npm install
It couldn't find the package.json file under the '/builds' directory.
As the error says:
npm ERR! enoent ENOENT: no such file or directory, open '/builds/****/package.json'
Please make sure your package.json is checked to git and is available there in the build directory.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | raedshari |
