WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.2k forks source link

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 closed 6 years ago

mintplugins commented 6 years ago

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):

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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.

kienstra commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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

danielbachhuber commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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

vishkpanicker commented 5 years ago

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

azanwar30 commented 5 years ago

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 commented 5 years ago

on windows, run terminal as Administratior work fine for me

ismaildenzzz commented 5 years ago

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 commented 5 years ago
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 commented 5 years ago

In my case npm set strict-ssl false

cs-manughian commented 5 years ago

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 commented 5 years ago

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

It works, thanks mate....

nealeu commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

sergegl commented 5 years ago

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.

zagrev commented 5 years ago

I wonder if this has something to do with the number of open files? I am having this problem currently, but only on the build server. We use a Jenkinsfile w/Docker, so the build occurs in a container that has never installed anything before. It was working early this week but now consistently fails.

tousifhasanzai commented 5 years ago

I faced same issue which was solved by removing package-lock.json file

rohan-baranwal commented 5 years ago

I am still getting same issue

`npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\karma\node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! path D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm ERR! Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js' npm ERR! { [Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js'] npm ERR! cause: npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js' npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR! path: npm ERR! 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules\.staging\typescript-33007fc3\lib\tsserverlibrary.js' }, npm ERR! stack: npm ERR! 'Error: EPERM: operation not permitted, unlink \'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules\.staging\typescript-33007fc3\lib\tsserverlibrary.js\'', npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR! path: npm ERR! 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules\.staging\typescript-33007fc3\lib\tsserverlibrary.js', npm ERR! parent: 'angularpwa' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). npm WARN tar ENOENT: no such file or directory, open 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\@angular\common-6157584c\upgrade\package.json' npm WARN tar ENOENT: no such file or directory, open 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\@angular\common-6157584c\upgrade\upgrade.d.ts' npm WARN tar ENOENT: no such file or directory, open 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa\node_modules.staging\@angular\common-6157584c\upgrade\upgrade.metadata.json'`

I tried deleting node_modules, doing npm i again, clear npm-cache by force. Still getting same issue

zagrev commented 5 years ago

My solution was to install git on the server.that removed all the errors.

Get Outlook for Android

On Wed, Oct 16, 2019 at 12:36 AM -0400, "Rohan Baranwal" notifications@github.com wrote:

I am still getting same issue

`npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\karma ode_modules\chokidar ode_modules\fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! path D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js

npm ERR! code EPERM

npm ERR! errno -4048

npm ERR! syscall unlink

npm ERR! Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js'

npm ERR! { [Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js']

npm ERR! cause:

npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js'

npm ERR! errno: -4048,

npm ERR! code: 'EPERM',

npm ERR! syscall: 'unlink',

npm ERR! path:

npm ERR! 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js' },

npm ERR! stack:

npm ERR! 'Error: EPERM: operation not permitted, unlink 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js'',

npm ERR! errno: -4048,

npm ERR! code: 'EPERM',

npm ERR! syscall: 'unlink',

npm ERR! path:

npm ERR! 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging\typescript-33007fc3\lib\tsserverlibrary.js',

npm ERR! parent: 'angularpwa' }

npm ERR!

npm ERR! The operation was rejected by your operating system.

npm ERR! It's possible that the file was already in use (by a text editor or antivirus),

npm ERR! or that you lack permissions to access it.

npm ERR!

npm ERR! If you believe this might be a permissions issue, please double-check the

npm ERR! permissions of the file and its containing directories, or try running

npm ERR! the command again as root/Administrator (though this is not recommended).

npm WARN tar ENOENT: no such file or directory, open 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging@angular\common-6157584c\upgrade\package.json'

npm WARN tar ENOENT: no such file or directory, open 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging@angular\common-6157584c\upgrade\upgrade.d.ts'

npm WARN tar ENOENT: no such file or directory, open 'D:\Code\PWA\PWA - Working Model\Angular Model\angularpwa ode_modules.staging@angular\common-6157584c\upgrade\upgrade.metadata.json'`

I tried deleting node_modules, doing npm i again, clear npm-cache by force.

Still getting same issue

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

danny-p93 commented 5 years ago

Close the vs code and go to directory via terminal and install npm from the terminal. this worked for me aswell

I had the same issue, after i transferred the dependencie-property of one project to another and executed npm i in the new Folder and it broke after some seconds. My guess is that in my special case it is related with WSL. I startet working with VScode on Windows, recently enabled WSL and installed the Ubuntu 18.04 App. Within that app i installed Node for Linux and made some other configs to run that WSL-Ubuntu properly on my System. Then i found the WSL-Remote Extension for VScode. After that i was able to run a Linux terminal in my Windows-VScode, start node, use git (without git bash) and everything. Just the npm i didn't work in VScode (aswell as in the Ubuntu app). After i closed VScode and run npm i in the WSL app again eveything worked fine.

dmark commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

rashmiraj06 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

renielsalvador commented 4 years ago

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 commented 4 years ago

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

It worked.

Dimkarodinz commented 4 years ago

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

vimalroy1250 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

tonykaram1993 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 ?