Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM "ENOENT: no such file or directory error" when installing Sails.js dependencies with Node 8.9.4 LTS

People also ask

What is Package-lock JSON?

package-lock. json is automatically generated for any operations where npm modifies either the node_modules tree, or package. json . It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.

Why do node modules go into .staging folder?

staging" means, those dependencies are getting downloaded so for the temporary basis it keeps all those dependencies under ". staging" folder. Once all gets downloaded properly then it will showcase them under node_modules only.


Try deleting the package-lock.json file.


No permission, no internet issue, it's just a general issue of npm. I solved the problem with yarn.

yarn install

Or you can use no-optional flag.

npm install --no-optional

For me, it turned out these errors were hiding the real underlying problem, which was that my credentials for a third-party npm repository (azure devops) had expired. I had to re-run vsts-npm-auth -config .npmrc to update the token in my .npmrc file.


Deleting and regenerating 'package-lock.json' usually solves this issue however that's inherently risky because you will likely be upgrading multiple packages at a time.

In my case it turned out that there was one specific package version that package-lock.json was referencing, that was 5 levels deep in the dependency. That version no longer existed at the npm registry so it caused the install to break. I had to find which package was pulling in this dependency and upgrade that one to resolve the issue.


In my case, I tried deleting package-lock.json, clearing and verifing the npm cache, removing node_modules, even stopping the antivirus (W10 machine) and was still getting this error.

I somehow fixed it by running npm update before npm install, which creates a new package-lock.json:

del /f package-lock.json
rd /s /q node_modules
npm cache clean
npm cache verify
npm update
npm install

Just delete package-lock.json file and then install package(s) you want. All will work.