"Cannot save" while running webpack hotreload or nodemon in Bash on Windows
In a NodeJS project.
I use Webstorm 2016.3.3 on Windows side.
Running webpack-dev-server (also tried running nodemon with Babel without webpack) in Bash on Windows to enable hot reload dev environment.
When I try to save a file, I get the error:
```
Following errors occurred on attempt to save files:
Cannot save C:\Users\xxx\xxx\src\index.js.
The file left unchanged.
Your changes were written to index.js___jb_tmp___.
```
To reproduce this error, run commands in Bash on Ubuntu on Windows
```
yarn global add create-react-app
create-react-app test-webstorm
cd test-webstorm
yarn start
```
Then on Windows Webstorm 2016.3.3, open project folder test-webstorm.
Navigate to `./src/App.js` and change anything. Hit save. Then error will pop up/
Then error will pop up.
This issue is stopping our whole team from using WebStorm in Windows.
Things are all fine with Atom IDE (thus we are forced to use ATOM now); or Webstorm on Mac OS.
请先登录再写评论。
Does the problem only occur when using Bash shell to run the app? Did you try using cmd.exe, WewbStorm built-in terminal, or NPM tool window in WebStorm?
Same here for me!
The problem only occurs using Bash shell / WSL to run webpack-dev-server. Running webpack-dev-server in cmd /powershell or other Windows based terminals works.
Nevertheless, it would be awesome to find a solution.
May be a problem with accessing Linux file system from Win32 app. See https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/, https://github.com/SublimeTextIssues/Core/issues/1471
All my files are located within the Windows file system. And it looks like its the same for @Ivawzh.
Following the advises of Microsoft it should be save to use them from Windows and Linux/Bash. Mine are located unter C:/source/* and respective /mnt/c/source/*
please provide your idea.log. 'Cannot save' errors usually indicate permissions issue - either current user is not permitted to modify the file, or the file is locked by other process and thus can't be accessed
I found the solution for this problem. I needed to uncheck the "safe write" option under Appearance & Behavior > System Settings.
Hmmm... This option may indeed cause problems with webpack hot reloading (https://webpack.github.io/docs/webpack-dev-server.html#working-with-editors-ides-supporting-safe-write, issue is fixed in webpack 2). But I'm not sure how it affects a possibility to save a file - if WebStorm can't replace existing file because of insufficient permissions/locking (as indicated by 'Cannot save' error), it shouldn't be able to modify it directly as well
Just one idea: the message means that Webstorm succeeded in writing new file content to a temp file ('index.js___jb_tmp___') but failed to rename the original one to this name. May be, it doesn't have permissions to delete files in the directory, but can overwrite original file?
It has something to do with permissions. Please if you find a solution let me know. I still have this problem.
Please try a solution from https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000082850/comments/115000105390 - does it help?
Yes this works but now I have other problem. I killed webpack. Then I used git stash to clean dir. Then when I wanted to switch branches I got the permission denied again. I just got to figure out what process locks my files I guess.
I used process explorer and found out that there were more then ten nodejs processes locking my files. When I close webstorm the nodejs processes are gone and the locks are released. Are these processes needed in order to use Webstorm correctly?
Yes this works but now I have other problem. I killed webpack. Then I used git stash to clean dir. Then when I wanted to switch branches I got the permission denied again. I just got to figure out what process locks my files I guess.
- When using git stash I already got the permission denied.
@Elena removing "safe write" indeed fixes the problem.
Atom, Hyper or Visual Studio Code do not have problems in the same scenario.