TypeScript: node_modules/@types cannot be deleted on Windows
Search Terms: is:issue is:open “visual studio”
Code
npm run reset
"reset": npx rimraf node_modules
"devDependencies": { ...babel }
Expected behavior: node_modules files are deleted
Actual behavior: error: EPERM: operation not permitted… blah blah… node_modules/@babel/types/lib/index.js.flow
Related Issues: Exactly this issue (https://github.com/microsoft/TypeScript/issues/29407) but instead of VSCode it doesn’t work in VS2019 (16.1.3 on windows 10)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 24
- Comments: 30 (9 by maintainers)
Closing this so anyone who still faces issue can open new issue with concrete steps to repro and be able to investigate
Repro (for an angular project at least, extensions disabled):
Extensions: none
Windows 10 1903 Build 18362.207, but it also happens to my colleagues on 1809.
My setup and situation is the same as @Pike96 . VS Code/tsserver is holding lock on lots of my project’s source code files (which aren’t open in VS code editor tabs) and lots of \node_modules\ files. Restarting the tsserver is my work-around.
@biltongza I just ran exactly those steps without any problems
@RyanCavanaugh no action was taken to “fix” the old issue and I’m pretty sure it was ever fixed, just not verified correctly. https://github.com/microsoft/TypeScript/issues/29407 has 51 votes and should still be treated as your #2 voted bug.
We are running into this as well on our team. When we do a clean build, the build fails on a rimraf of one of our node_modules dirs. I’ve tried restarting the TS server and that doesn’t really help. SysInternals’ handle.exe shows the folder as locked by code.exe:
But the command line shows that instance of code.exe is running the tsserver. This is driving our team crazy. Having to exit VSCode just to do a build is a PITA.
Have been tracking this issue for more than half a year, also have given up on VSCode for that long. Cannot believe that this is still a problem.
In my case, I have several local ts libraries that output to
distfolder. My main app relies on those libraries, and also output todistfolder. There are .ts files in my libraries’ output files. So TS server in VSCode holds the files indist, which prevent me from deletingdistfolder before building the whole thing. If I disabletypescript-language-features, then the problem is gone.All related issues that I can found for my problem are closed and point to #29407 and this one.
#29407 was closed as an issue with electron, but this issue shows that there is another issue with the same symptoms since this one is about VS2019, which doesn’t use electron as far as I’m aware.
See also https://github.com/Microsoft/vscode/issues/72535. Pretty annoying to have to close the editor just to build Ng/TS projects, losing undo history. (Assuming it wasn’t fixed in TS 3.5 and is a TS issue rather than a VS or VS Code one…might be fixed in the Insider build, though!)