NPM Install Issue inside (docker container) Vagrant

Sathish
2 min readJun 28, 2020

Recently, I was facing npm install issue inside (docker container) vagrant (centos8 box)with Mac OS. My colleague was facing this issue for long time. Also, there is no proper working solution online. I desperately wanted to fix this, so that, others don’t spend hours in fixing this. Here is my experience on how I resolved this issue.

When I npm install mongodb , I got the following error

enoent ENOENT: no such file or directory, open node_modules/chalk/node_modules/ansi-styles/package.json.3726888246

Initially, I thought, ansi-styles package was missing, installing this might fix the issue. When I tried installing ansi-styles package, I was getting similar (above) error but with different package.

I was little confused, so I tried, installing other package (generic-pool), unfortunately, this package got installed successfully. But, I was facing the above (ENOENT )error for most of the packages.

Then, I thought, let’s install in host machine instead. I was able to install all packages successfully. This gave me a hunch. It’s problem with the (vagrant) virtual box and node.

So, I slightly shifted my focus, tried installing the same packages inside vagrant, but this time, not in mounted path (in unmounted directory). I was able to install successfully. This gave me clear picture, the issue was with mounted directory inside vagrant (+ npm install).

Few of my colleagues didn’t face any issues , trying to install npm packages inside (docker container) vagrant. I was also digging online for hours to some how solve it. In one of the link, I found, it might be due to the version of virtual box (especially 5.*). But, I was using virtual box version 6.0.*. I didn’t ignore this link, since it’s working for others, but not working for few.

I immediately upgraded the version of virtual box version from 6.0.22 to 6.1.10. Here is the link to download latest virtual box

https://download.virtualbox.org/virtualbox/6.1.10/VirtualBox-6.1.10-138449-OSX.dmg

This thrown another error, version of vagrant is not compatible. Then I destroyed my current vagrant box , upgraded to latest version of vagrant (2.2.9).

Here is the link to download latest vagrant.

https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.dmg

Note: vagrant boxes will not be compatible after upgrading, so we need to recreate box(es)again after upgrade.

After upgrading virtual box and vagrant (also setting new centos8 box), npm install mongodb issues was resolved and I was able to install all packages successfully inside (docker container) vagrant.

Here is what I learned — If you are facing any issue, don’t give up, most of the technical issues are not impossible, sleep on it for sometime, so that we can get different directions.

--

--

Sathish

Software Architect ★ Developer ★ Troubleshooter