nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.69k stars 2.27k forks source link

Error: EPERM: operation not permitted, lstat when run reset or clear-cache #11624

Closed hmendezm closed 2 months ago

hmendezm commented 1 year ago

Current Behavior

error EPERM show up.

Expected Behavior

successful reset workspace

Steps to Reproduce

I am running this as administrator run nx reset

Failure Logs

PS C:\Projects\pivotal-mfe> nx reset

NX Resetting the Nx workspace cache and stopping the Nx Daemon.

This might take a few minutes.

NX Daemon Server - Stopped

nx.js reset

Clears all the cached Nx artifacts and metadata about the workspace and shuts down the Nx Daemon.

Options: --help Show help [boolean] --version Show version number [boolean]

Error: EPERM: operation not permitted, lstat '\?\C:\Projects....\node_modules.cache\nx\d\daemon.log' at lstatSync (node:fs:1574:3) at rimrafSync (node:internal/fs/rimraf:180:13) at node:internal/fs/rimraf:253:9 at Array.forEach () at _rmdirSync (node:internal/fs/rimraf:250:7) at fixWinEPERMSync (node:internal/fs/rimraf:304:5) at rimrafSync (node:internal/fs/rimraf:200:14) at node:internal/fs/rimraf:253:9 at Array.forEach () at _rmdirSync (node:internal/fs/rimraf:250:7) { errno: -4048, syscall: 'lstat', code: 'EPERM', path: '\\?\C:\Projects\....\node_modules\.cache\nx\d\daemon.log' }

Environment

Node : 18.7.0 OS : win32 x64 yarn : 1.22.5

nx : 14.5.6 @nrwl/angular : 14.5.6 @nrwl/cypress : 14.5.6 @nrwl/detox : Not Found @nrwl/devkit : 14.5.6 @nrwl/eslint-plugin-nx : 14.5.6 @nrwl/express : Not Found @nrwl/jest : 14.5.6 @nrwl/js : 14.5.6 @nrwl/linter : 14.5.6 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/nx-cloud : Not Found @nrwl/nx-plugin : Not Found @nrwl/react : Not Found @nrwl/react-native : Not Found @nrwl/schematics : Not Found @nrwl/storybook : 14.5.6 @nrwl/web : 14.5.6 @nrwl/workspace : 14.5.6 typescript : 4.7.4

Local workspace plugins:

Community plugins: @ngrx/component-store: 14.0.2 @ngrx/effects: 14.0.2 @ngrx/entity: 14.0.2 @ngrx/router-store: 14.0.2 @ngrx/store: 14.0.2 @ngrx/store-devtools: 14.0.2 devextreme-angular: 21.2.9 ngx-build-plus: 14.0.0 @ngrx/schematics: 14.0.2

stevebeauge commented 1 year ago

If it can help, I faced the same issue.

This was due to running VSCode with NX extension. Shutting down VSC then nx reset worked in my case.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

stevebeauge commented 1 year ago

The issue shouldn't be closed. I still have regular issue with locked files. Shutting up VSCode only reduce the frequency of troubles

davidmwhynot commented 1 year ago

I'm getting this even after shutting down vscode and ensuring that Code.exe is not running in task manager. I had to kill a background node.exe process that persisted after VS Code was shutdown.

froth30 commented 1 year ago

I'm using WebStorm, and I have encountered this issue several times now. I found that killing the background git.exe process fixes the issue. I think I even left the IDE open while doing this, then I was able to delete node_modules and rerun npm install before the git.exe process started up again.

image

dbehmoaras commented 10 months ago

I solved this by killing both VSCode and Node Runtime Env in Task Manager (WinServer 2016 but should work for all instance of Win10 that I know of. )

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

cpdekker commented 4 months ago

I am still seeing this issue, also when running in VSCode. Closing VSCode and running nx reset in powershell worked, but once I re-opened vs code I couldn't serve my project

MaxKless commented 3 months ago

Hey everyone! Thanks for the report and investigations you already put in. Good news, I'm working on a fix to this as we speak. The original daemon.log error should already happen a lot less frequently since we moved the cache out of node_modules. I'm now working on removing even more files that we potentially lock out of there so it should be even better soon. I'll keep you posted once the PR is up

TheDevelolper commented 2 months ago

Hey @MaxKless just wondering if you had any news on this? It's also affecting me

MaxKless commented 2 months ago

As of 18.3.4, this error shouldn't appear anymore. We copy the .node file (which is locked by the OS) outside of node_modules before using it. Make sure you do these two things:

If you still run into this error after updating to the latest versions & running nx reset & restarting vscode, please create a new issue with the error you're seeing and ping me on it :) Here's the PR that fixes this for reference https://github.com/nrwl/nx/pull/22648

github-actions[bot] commented 1 month ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.