Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't NPM Install: ENOENT: no such file or directory .staging/core-js-c2a9e69c (solved with rm -rf node_modules && npm install) #9474

Closed
mintplugins opened this issue Aug 30, 2018 · 49 comments
Labels
[Type] Build Tooling Issues or PRs related to build tooling

Comments

@mintplugins
Copy link

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:

  1. Install Local by Flywheel and install WordPress.
  2. Clone gutenberg repo into the wp-content/plugins directory
  3. Attempt to run npm install while in that directory in Terminal on Mac
  4. 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:

screen shot 2018-08-30 at 11 07 26 am

Any assistance would be highly appreciated.

@Soean
Copy link
Member

Soean commented Aug 30, 2018

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?

@mintplugins
Copy link
Author

@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.

@mintplugins
Copy link
Author

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.

@designsimply designsimply added Needs Testing Needs further testing to be confirmed. Needs Technical Feedback Needs testing from a developer perspective. labels Aug 31, 2018
@kienstra
Copy link
Contributor

kienstra commented Sep 2, 2018

@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

@danielbachhuber
Copy link
Member

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?

@ntwb
Copy link
Member

ntwb commented Sep 11, 2018

Not tracked anywhere, it's a common issue, maybe it should be documented in the repo somewhere

@danielbachhuber
Copy link
Member

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.

@mintplugins
Copy link
Author

@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.

@mintplugins
Copy link
Author

@danielbachhuber False alarm - it does seem to have worked now! Great - thank you!

@designsimply designsimply removed Needs Technical Feedback Needs testing from a developer perspective. Needs Testing Needs further testing to be confirmed. labels Oct 16, 2018
@designsimply designsimply changed the title Can't NPM Install: ENOENT: no such file or directory .staging/core-js-c2a9e69c Can't NPM Install: ENOENT: no such file or directory .staging/core-js-c2a9e69c (solved with rm -rf node_modules && npm install) Oct 16, 2018
@vishkpanicker
Copy link

Close the vs code and go to directory via terminal and install npm from the terminal.

@azanwar30
Copy link

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

@TechNov
Copy link

TechNov commented Jan 31, 2019

on windows, run terminal as Administratior work fine for me

@ismaildenzzz
Copy link

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.

@chenyang48671155
Copy link

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?

@rafalfaro-actr
Copy link

rafalfaro-actr commented Mar 15, 2019

In my case npm set strict-ssl false

@cs-manughian
Copy link

In my case, I removed the node_modules folder and the package-lock.json and then I was able to successfully run npm i.

@sociojs
Copy link

sociojs commented May 3, 2019

Close the vs code and go to directory via terminal and install npm from the terminal.

It works, thanks mate....

@nealeu
Copy link

nealeu commented Jun 3, 2019

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.

@CoderHana
Copy link

I've tried to install the package in CMD instead of the terminal of the VSCode. use CMD (Command Prompt). it works for me

@cemilakkoc
Copy link

That may sound a bit weird but i fixed it by creating a new folder in a different path.

@sergegl
Copy link

sergegl commented Aug 8, 2019

Some of my co-workers are getting the same error, I have an angular 8 - nx project, that i put on our internal source control. my local and build machines works fine, some people get "npm WARN tar ENOENT: no such file or directory, open...." when running npm install.
I did try deleting the node_packages folder, deleting package-lock.json, updating node etc..
So far i have no clue why it's happening.

@dmark
Copy link

dmark commented Oct 25, 2019

In my case, I removed the node_modules folder and the package-lock.json and then I was able to successfully run npm i.

I was getting the same error in a personal project and this resolved the issue for me. Remove the node_modules/ directory and remove package-lock.json.

@ChuckByram
Copy link

I get this problem if my PackageA has a local path dependency on my PackageB (file:../PackageB), which has its own dependency list, and I don't do an npm install in PackageB prior to npm install in PackageA.

cd PackageB
rm -rf node_modules
cd ../PackageA
rm -rf node_modules
npm install

will give me this problem. If I npm install in PackageB before PackageA, then it's ok.

I solved this by using yarn install.

@sachin27sharma
Copy link

Am still getting this issue with below npm and node versions. This is happening for any new projects too, without any package-lock.json file.
Tried deleting node_modules, clearing npm cache, running visual studio code in admin mode etc, but still coming.
npm@6.9.0
node@10.16.3

Any advise?

Thanks

@arekstryjski
Copy link

I had similar problem after upgrading to Ubuntu 19.04 and creating new user.
In the end I reinstalled node/npm and it worked.

My versions now:
node@12.13.1
npm@6.12.1

@BatStak
Copy link

BatStak commented Dec 11, 2019

If you unpublish a version on a local repository and republish it, you may have this issue.

NPM 5.6.0 (at least) do not always warn you about wrong sha512 checksum on packages. When you install a package, there is some cache on already installed packages (sha512 checksums).

The command npm cache clear --force seems to not work as intended on my system (Windows10).
Which result in this issue even with cache cleared.

I had to publish a new version of the package involved and the error has gone.

@Ahmed-Moftah
Copy link

Just delete package-lock.json file and then install packages you want with npm install . All will work.

@rashmiraj06
Copy link

Try:
Deleting package-lock.json and then run npm install.

If the issue still persists check if you have a global version of any of the packages installed.
This can happen if you have a global version of a package that clashes with a local version of a package.

@sachin27sharma
Copy link

Actually, figured out this is due to symlink mapped to user folder being shared by multiple node instances. Just running npm install from powershell before opening vs code resolves it all the time. Earlier, even after deleting package-lock.json or a fresh project, it was still complaining.

@willparker123
Copy link

This is the only true fix for this issue; please vote this man up!

@renielsalvador
Copy link

Im getting the same issue. deleting the package-lock.json is not an option in my case. How do you guys fixed it? This is bugging me for 2 days now. Need help

@sainthkh
Copy link
Contributor

I met this issue on Windows. I updated node and npm to the latest LTS version and rerun npm i.

It worked.

@Dimkarodinz
Copy link

In my case I had missing .npmrc file with custom package registry (and access of some packages access as result)

@vimalroy1250
Copy link

For me
rm -rf node_modules/
npm install
npm update

worked for me. Or just try npm update

But before all these please check the version is updated or not.

@eidottermihi
Copy link

None of the above solutions worked for me on Windows 10 and Powershell (run as user / run as administrator).

I have then switched to using the Git Bash (included in Git for Windows, https://gitforwindows.org/), which resolved the issue for me.

@vimalroy1250
Copy link

For me
rm -rf node_modules/
npm install
npm update

worked for me. Or just try npm update

But before all these please check the version is updated or not.

This is for Linux terminal. Not for windows.

@kunal13053
Copy link

I had the same issue. But, none of the above solutions worked for my case. I did the git clone again in a new folder and then it worked fine for me. I am using windows 10 and git bash terminal.

@msx752
Copy link

msx752 commented Jun 5, 2020

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

i had same issue today and your solution is worked

npm info 'v6.14.4'
nodejs info 'v12.18.0-x64'

@manny42g
Copy link

manny42g commented Jul 29, 2020

I had similar issues as ya'll on Windows due to a package-lock.json file one directory above. Removed the file and installed flawlessly.

@ironsoul0
Copy link

Nothing here helped me. Turned out I did not have git installed on my fresh server.

apt install git solved my problem.

Did not know npm requires git as a dependency.

@memartinez06
Copy link

I have presented the same error due to npm cache problems. Run npm install --cache /tmp/empty-cache

@tonykaram1993
Copy link

tonykaram1993 commented Dec 9, 2020

I have no clue if this is going to help anyone, and to be honest I am not even sure if this fixed my issue. I tried installing/deleting and reinstalling a billion times nothing helped.

One of the two fixed my issue:

  1. I had my server running while installing a package and it messed stuff up (my thinking is since hot reload is on, I can see the error disappear in the dev console then I know the package was installed correctly). I installed and deleted billions of times, it didn't work. I turned off the server and then deleted node_modules and yarn.lock then redid yarn again and voila! All worked.
  2. I discarded all my changes to package.json and then re added the packages yarn add package-name one by one.

Good luck!

@bhargavgohil25
Copy link

In my case, I removed the node_modules folder and the package-lock.json and then I was able to successfully run npm i.

Worked for me perfectly !
Thanks : )

@pravin-d
Copy link

pravin-d commented Jan 29, 2021

Deleting package-lock.json is quite risky especially if you on slightly old projects.. According to this post it might be due to race condition.. https://stackoverflow.com/a/52997767/3050426
Can anyone verify this ?

richardxia added a commit to ShelterTechSF/askdarcel-web that referenced this issue Jul 12, 2021
The Internet seems to believe that "no such file or directory, rename"
issues are due to a race condition in NPM, and that deleting and
regenerating package-lock.json works around the issue. This seems to fix
the issue for us.

WordPress/gutenberg#9474 (comment)
richardxia added a commit to ShelterTechSF/askdarcel-web that referenced this issue Jul 12, 2021
The Internet seems to believe that "no such file or directory, rename"
errors we are running into are due to a race condition in NPM, and that
deleting and regenerating package-lock.json works around the issue. This
indeed appears to fix the issue for us.

WordPress/gutenberg#9474 (comment)
richardxia added a commit to ShelterTechSF/askdarcel-web that referenced this issue Jul 12, 2021
The Internet seems to believe that "no such file or directory, rename"
errors we are running into are due to a race condition in NPM, and that
deleting and regenerating package-lock.json works around the issue. This
indeed appears to fix the issue for us.

WordPress/gutenberg#9474 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

No branches or pull requests