![](/style/images/good.png)
![](/style/images/bad.png)
How to fix: npm ERR! enoent ENOENT: no such file or directory, rename
source link: https://www.codejourney.net/2021/04/how-to-fix-npm-err-enoent-enoent-no-such-file-or-directory-rename/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to fix: npm ERR! enoent ENOENT: no such file or directory, rename
![npm_rename_error.png](https://www.codejourney.net/wp-content/uploads/2021/04/npm_rename_error.png)
I recently struggled for a while with an npm
error thrown when executing npm install
of some package. The error message was npm ERR! enoent ENOENT: no such file or directory, rename 'D:\\WebApp\\node_modules\\lz-string' -> 'D:\\WebApp\\node_modules.lz-string.DELETE'
Finally, I found a solution and a reason for that issue.
The error occurred when I was trying to install @testing-library/react
npm package. It looked like that:
Hotfix
If you ever get this error, the hotfix is to follow these steps:
- delete
node-modules
folder - run command
npm cache clean --force
- run command
npm install
- install the package again with
npm install your-package-name
It should all work fine after that. But it’s only a hotfix, a solution for now to unblock you.
Coldfix (solution)
The real reason for this issue in my case turned out to be related to jest
. However, not to the testing library itself, but to jest extension for Visual Studio Code.
The reason for the issue is the jest tests runner working in the background. You can see that in the VS Code bottom bar:
![Visual Studio Code - jest runner](https://i2.wp.com/www.codejourney.net/wp-content/uploads/2021/04/vsCode_jest_runner.png?resize=320%2C158&ssl=1)
The real solution is to disable jest runner when installing new packages. You can do it with a Jest: Stop Runner
command in Ctrl+Shift+P:
![npm ERR! enoent ENOENT fix in Visual Studio by stopping jest runner](https://i0.wp.com/www.codejourney.net/wp-content/uploads/2021/04/VSCode_jest_stop_runner.png?resize=777%2C246&ssl=1)
I don’t know exactly why this is an issue. I guess jest runner is blocking some files in node-modules
, so they cannot be renamed/processed. I hope it helps you too
Related Posts
- SQLite-Net Extensions – one-to-one relationships
In this second short post from SQLite-Net Extensions series, we're going to see how to…
- SQLite-Net Extensions – one-to-many relationships
In the 3rd post from SQLite-Net Extensions series we are covering the last type of relationship…
- SQLite-Net Extensions - many-to-many relationships
In today's post we're going to see what is SQLite-Net Extensions ORM and how to…
javascriptnpmnpm ERR! enoent ENOENTnpm errornpm install packagereact
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK