Can't NPM Install: ENOENT: no such file or directory .staging/core-js-c2a9e69c (solved with `rm -rf node_modules && npm install`)
Describe the problem
When attempting to run npm install in the Gutenberg directory, it fails with this error:
`ENOENT: no such file or directory, rename '[removed path to my local WP enironment]/wp-content/plugins/gutenberg/node_modules/.staging/core-js-c2a9e69c' -> '[removed path to my local WP enironment]/wp-content/plugins/gutenberg/packages/hooks/node_modules/core-js'
To Reproduce Steps to reproduce the behavior:
- Install Local by Flywheel and install WordPress.
- Clone gutenberg repo into the wp-content/plugins directory
- Attempt to run
npm installwhile in that directory in Terminal on Mac - Error above happens and npm is not installed.
Expected behavior I expect NPM to install without any issues.
Desktop (please complete the following information):
- OS: OSX Version 10.11.6
- Browser: Chrome Version 68.0.3440.84
** Additional Information** The node_modules directory does get created before it fails, and I see a .staging file in that directory during setup, but it is ultimately removed by the time the error happens in Terminal. See screenshot of node_modules directory:
Any assistance would be highly appreciated.
Delete package-lock.json and run npm install.
Hey @mintplugins,
which version of node and npm do you use?
Are you using Malwarebytes on your computer?
@Soean Thanks for the response.
NPM version: 5.6.0 Node version: v8.11.4
I do not use Malwarebytes.
Unfortunately, deleting package-lock.json did not result in any changes while running npm install. I am still getting the same error.
I just upgraded NPM to version 6.4.1, but it did not result in any changes either. I am still getting the same error.
@mintplugins, thanks for opening this issue.
After running npm install, I'm also seeing a similar error message to the one you reported.
npm ERR! path <my-local-path>/gutenberg/node_modules/@wordpress/hooks/node_modules/core-js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '<my-local-path>/gutenberg/node_modules/@wordpress/hooks/node_modules/core-js' -> '<my-local-path>/gutenberg/packages/i18n/node_modules/core-js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Node: v8.11.4
NPM: v6.4.1
I've run into this issue quite often ~1 month ago. rm -rf node_modules && npm install resolves the issue for me.
@ntwb Is this issue being tracked somewhere?
Not tracked anywhere, it's a common issue, maybe it should be documented in the repo somewhere
maybe it should be documented in the repo somewhere
I wasn't able to find a good place for this in our existing documentation. We have CONTRIBUTING.md, but it doesn't have a section for debugging / known issues like this. Plus, the issue would ideally be resolved, not something developers have to live with.
With this being said, searching GitHub issues is fairly standard practice. Given the specificity of this error, I think we can have it live in GitHub issue history for now.
@danielbachhuber I tried running the code you provided, but after running it, which took about 20 minutes to complete, I tried to run npm install again, and unfortunately I am still getting the exact same error. That code does not seem to have resolved anything in my situation.
@danielbachhuber False alarm - it does seem to have worked now! Great - thank you!
Close the vs code and go to directory via terminal and install npm from the terminal.
My node version is 8.12.0 npm version is 6.4.1
I also got this issue today only & I have resolved it by removing package-lock.json file & then try to install packages with --unsafe-perm Example -
rm -rf package-lock.json npm install pachageName --unsafe-perm
It works for me
on windows, run terminal as Administratior work fine for me
If there is a character or a space other than the English characters from the user name, it can also be caused by this.
I'm talking about the installation of global packages. If you are installing a package on a specific project, it may also be caused by the lack of package.json.
npm ERR! path D:\TutsGalaxy\angular-and-node\package.json npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open 'D:\TutsGalaxy\angular-and-node\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! D:\Program Files\nodejs\node_cache\_logs\2019-02-14T12_50_27_473Z-debug.log
How do you solve this problem?
In my case npm set strict-ssl false
In my case, I removed the node_modules folder and the package-lock.json and then I was able to successfully run npm i.
Close the vs code and go to directory via terminal and install npm from the terminal.
It works, thanks mate....
I've just come across this and thought it worth adding my experience with the same error.
Our build passes, but executing the same commands locally doesn't.
One thing I found was that our build (on Bitbucket Pipelines) was using npm install rather than npm ci. It seems that this is essential for repeatable builds.
I've tried to install the package in CMD instead of the terminal of the VSCode. use CMD (Command Prompt). it works for me
That may sound a bit weird but i fixed it by creating a new folder in a different path.