nx: Error: ENOENT: no such file or directory" for deleted file
This bug is already described here https://github.com/nrwl/nx/issues/3370 and recently, there has been a request to have it re-opened but seems still not.
The present ticket was opened in the hope that this will be fixed once and for all. Indeed, this bug is detrimental to the developer’s workflow. Therefore, questioning the use of NX. The next information in this ticket is mostly repeated from https://github.com/nrwl/nx/issues/3370.
Note
In my case, it was resolved after making sure that the nx root folder was the git root folder.
Not working:
project
- .git/
- nx folder
- documentation
- security
- ...
Working:
project
- nx folder
- .git/
- documentation
- security
- ...
However, there is a need for the sub-folder structure for other developers and sometimes, it is not possible to change the folder structure. In addition, the different mentioned work arounds (git stash, git -ma) are not considered the proper solutions as NX should correctly handle the deleted, renamed or moved files.
Current Behavior
After deleting any file in the repository there is an error with yarn start (also with other “affected” commands such as yarn affected:lint, yarn affected:test)
“Error: ENOENT: no such file or directory {{old location of the file}}”.
Note
This is also affecting the components importing those files as well as modification to the files itself in some cases (!). It is not related to NX cache but rather this https://github.com/nrwl/nx/issues/3370#issuecomment-858391601
Expected Behavior
Should not be an error after file is removed in case it is not used in project source locally. It also happens when renaming or moving any file around.
Steps to Reproduce
- create new workspace via npx create-nx-workspace@latest with Angular or React app
- run yarn start or affected:lint
- delete any component (eg. app.component.spec.ts)
- run yarn start or affected:lint again
- get error message
Failure logs
Error: ENOENT: no such file or directory, open {{old location of the file}} at Object.openSync (fs.js:458:3) at Object.readFileSync (fs.js:360:35) [...]
Environment
macOS Big Sur 11.2.3
git version 2.30.1
"@nrwl/cli": "12.5.8",
"@nrwl/cypress": "12.5.8",
"@nrwl/eslint-plugin-nx": "12.5.8",
"@nrwl/express": "12.5.8",
"@nrwl/jest": "12.5.8",
"@nrwl/linter": "12.5.8",
"@nrwl/next": "12.5.8",
"@nrwl/node": "12.5.8",
"@nrwl/react": "12.5.8",
"@nrwl/storybook": "12.5.8",
"@nrwl/tao": "12.5.8",
"@nrwl/web": "12.5.8",
"@nrwl/workspace": "12.5.8",
"typescript": "~4.3.5",
"next": "11.0.1",
"react": "17.0.2",
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 27
- Comments: 51 (1 by maintainers)
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! 🙏
Bump. This issue is very annoying. I do not want to be forced to commit after renaming/moving files.
@FrozenPandaz Could you remove the bot action for this issue? I don’t mind it might take a long time to fix this issue.
I can understand it is not the priority. However, it is just annoy to keep the bot away by making more useless comments, including this one.
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! 🙏
Same issue on v12.9.0
@pavandv you don’t have to commit to get rid of this error. Just do
git stashandgit stash popDefinitely shouldn’t be closed - I ran into this yesterday.
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! 🙏
@maxisam a fix would be better than a work around.
Hey thanks for reopening this. I have created the first issue for this bug https://github.com/nrwl/nx/issues/3370 , which is closed now. But I retrieve email notifications from github that people still facing this almost each day.
Originally we have aborted using nx because of this annoying issue. Now in my new angular and nest.js proj I would like to try NX again, but I do not understand why this bug is ignored for so long time by Nx team.
I consider the tool/product really cool. But do not understand why such an annoying thing is not fixed for so long
Le Bump
Just a friendly reminder, that this issue should not be closed.
Thank you!
@FrozenPandaz, I was able to reproduce the issue using your repo.
Steps (all commands are run from the
nx-workspacefolder):nx g component --name=TestComponent --export=falsenx test && nx lint.git add . && git commit -m "Adds TestComponent"appcomponent & fix the imports so that the project builds correctly:git add .nx test:just for the sake of helping someone out if you are still having issues with this:
https://github.com/nrwl/nx/issues/3370#issuecomment-1261391072
@evgeny-kirichuk Commit the changes. That works for me.
I’ve just faced the issue while trying to build the app. Stash - stash pop doesn’t help. What are the options in such a case? I just can’t build the app anymore.
To all subscribers of this issue: there seems to be progress in #7177 which is another clone of the originating issue.
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! 🙏
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! 🙏
Seriously, we are adding to global warming by making this kinda useless post just for the bot
Any comment on this issue NX creators/maintainers? This issue seems just ignored lol.
@vsavkin @FrozenPandaz
have the same issue with “@nrwl/workspace”: “12.7.2”
I’m also facing this after renaming a folder and running a build executor. I use
@nrwl/workspace@12.3.4and here is the stack trace:Running the command with
--skip-nx-cachedoes not fix the issue as well as removingnode_modules/.cache/nxcache folder.