Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While doing npm install getting an error as "No such file or directory open"

Tags:

node.js

npm

npm WARN tar ENOENT: no such file or directory, open 'C:{{File_Location}}\node_modules.staging\mocha-20835964\lib\browser\progress.js'

and Error message as npm ERR! Unexpected end of JSON input while parsing near '...int-stylish":"~0.1.3"'

I am trying the command npm-install in visual studio above is the error which I am getting.Please help me for the same.

like image 811
Pratyush Mayank Avatar asked Oct 13 '18 05:10

Pratyush Mayank


2 Answers

delete package-lock.json first. navigate to the root folder of your project and npm cache clean --force, then try npm install

like image 73
Milad Aghamohammadi Avatar answered Sep 28 '22 05:09

Milad Aghamohammadi


What happen for me to get this error was when I runned npm i and closed or stopped before it was finished. Then to try to "fix" it, I deleted the node_modules folder and runned npm i again and started getting this error.

And the reason why this happens and npm cache clean --force fixes the problem is that npm have a cache on the files that it have already downloaded, but when I remove node_modules, it can't find the files name that are cached and should be in the node_modules and gives this error/warning.

like image 36
Vencovsky Avatar answered Sep 28 '22 05:09

Vencovsky