Npm ERR! no such file or directory, open '/work/package.json' fails in CI but works locally

We are at the moment evaluating Circle. I have a docker-compose which fails to builds one of the container with reason npm install fails to find package.json which actually does exist in the working folder.

Dockerfile:

FROM node:10 as tester
RUN mkdir /work
WORKDIR /work
COPY package*.json ./
RUN pwd
RUN ls -l
RUN npm install

Console:

Step 15/17 : RUN pwd
—> Running in e9e01e747bbf
/work
—> 8aeed12b0fe2
Removing intermediate container e9e01e747bbf
Step 16/17 : RUN ls -l
—> Running in de7fb4488ec6
total 8
-rw-r–r-- 1 root root 77 Oct 18 01:13 package-lock.json
-rw-r–r-- 1 root root 201 Oct 18 01:13 package.json
Removing intermediate container de7fb4488ec6
Step 17/17 : RUN npm install
—> Running in bfce5777ee94
up to date in 0.668s
found 0 vulnerabilities

Successfully built 615274cb6279
Successfully tagged hello-circleci_tester:latest
Creating network “hello-circleci_default” with the default driver
Creating hello-circleci_dev_1 …

^@^@npm ERR! path /work/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open ‘/work/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/2018-10-18T01_14_29_411Z-debug.log
Stopping hello-circleci_dev_1 …

npm version: npm: ‘6.4.1’

We need to get this working asap as we only have limited evaluation window of the tool. Any help appreciated. cheers

What’s in the debug file /root/.npm/_logs/2018-10-18T01_14_29_411Z-debug.log?

Hi, a really dumb question but how can i download the /root/.npm/_logs/2018-10-18T01_14_29_411Z-debug.log given the container is destroyed after the failed run? Help appreciated

Go to your failed build, run it again with the SSH option, then you can use less/cat/nano etc to examine the file using a SSH session.

I ssh into the container built from image node:10 but there’s no log files from /root/.npm/
I can’t understand why npm install is looking for /work/package.json while the current folder of execution is inside /work . Help appreciated

Resolved. My volume attached from docker-compose overwrites the folder, hence deletes package.json

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.