cheslijones
cheslijones

Reputation: 9194

npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'

A bit stuck on this one. Taking a Grider course on Docker through Udemy.com.

I just keep getting the following error when I do:

docker run -p 3000:3000 -v /app/node_modules -v $(pwd):/app 5932996c40dc

npm ERR! path /app/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/app/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/2019-01-30T23_04_17_890Z-debug.log

I echo the command out because I want to see exactly what it is trying to execute and comes back as:

docker run -p 3000:3000 -v /app/node_modules -v /mnt/c/projects/courses/docker_kubernetes/frontend:/app 5932996c40dc

I run the image without the -v so that I can start the container and exec -it into it to see what is on the container. It does show everything as it should inside the container. It copied everything into /app in the container.

enter image description here

The command I used to build the image was docker build -f Dockerfile.dev . and remove the node_modules from the local version.

Here is a copy of my repo that has the Dockerfile and such in it: https://github.com/ishraqiyun77/docker_kubernetes.

Running in Windows Subsystem for Linux (WSL) on Windows 10 Pro, docker-client is running in WSL, docker-daemon is running in VMWare Workstation Player 15. I did make the .env for good measure with CHOKIDAR_USEPOLLING=true. Not convinced that this config is the issue yet, but who knows, it could be.

Also, there is no /root/.npm/_logs/2019-01-30T23_04_17_890Z-debug.log in either the container or the local file system.

I've also changed WSL to instead of having the path /mnt/c/projects... to just be /c/projects.

Upvotes: 4

Views: 8604

Answers (2)

Shubhankar Ranade
Shubhankar Ranade

Reputation: 101

I tried adding the location where my code is to the Shared Folder via Virtual Box as mentioned by Wenyan but it did not work.

What worked for me is I moved my code to C://Users//{username} as C Drive is mentioned as the storage location in Virtual Box. I had no problems in running docker commands after moving the code.

Upvotes: 1

Wenyan XIE
Wenyan XIE

Reputation: 46

I am also taking the Grider course on Docker through Udemy.com. And I met exactly the same problem as you. Since I am using Windows 10 Home Edition, I can't use Docker Desktop (Windows), instead, I have to use Docker Toolbox.

In my case, I am trying to run:

xwy52@JFC-DELL MINGW64 /d/Git/LearnDevOps/docker/images/frontend (master)
$ docker run -p 3000:3000 -v /app/node_modules -v $(pwd):/app 5d83ae77af14

And I met your problem, the solution for me is to configure another shared folder for the default virtual machine in VirtualBox, as seen in below screenshot: Configure Shared Folder for Default VM

Upvotes: 2

Related Questions