-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development server errors due to emacs file lock #9056
Comments
This started today for me too. I can't see what changed in my environment. A temporary workaround, until this is resolved, is to tell your Emacs to stop saving lock files: Try:
This has consequences, but will at least let us work for now with Emacs and React until someone figures out what's really going on. |
same here, I tried to extend |
just a temporay workaround.
|
Any progress on this? Does anyone know where the webpack config file is so that an exclude can be included? BTW: temporary workaround suggested in above should test for [jt]s at end so editting of regular js files also works. And, also handle lstat error e.g,
|
@seth4618 I believe it's at |
@smitchell556 The fix suggested by @misapprehand with my mods is working for me. |
The attempts I made were to exclude/ignore the files, not ignore the error. I'm glad that works though! |
setting watchOptions: {
ignored: /\.#|node_modules|~$/,
}, this will ignore emacs lock files, emacs backup files, and |
@orzechowskid Is that in the webpack config under |
ah, sorry about that. this is |
Cool, that seems like a good way to fix this since it’s directly through webpack’s config. It looks like there’s been discussion (#6303) about allowing custom configuration which would be ideal for this, but there’s no current support for it. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
So there is no good way getting around this without ejecting? |
You could try patching it as part of the set up process. It’s not ideal but it’s just a one and done thing for each project. |
Also the lockfiles can be disabled per project https://stackoverflow.com/questions/62567370/reactjs-local-server-crashes-after-editing-file-in-emacs-even-without-saving |
patching is what I ended up doing on my one c-r-a project, yeah; I added a postinstall script which mangles the webpack config file to add this fix. it's dirty but it'll work and you don't have to eject. |
I couldn't get this to work too and didn't want to use the exact solution to disable symlinks: #9056 (comment).
It's still bad but at least it's something more. |
See also: https://stackoverflow.com/a/62571200 You can disable lockfiles locally:
|
Another way to reproduce the issue:
Eidt index.js again. The server is broken by emacs lock file After comparing two yarn.lock files. The different version of watchpack causes the issue
issue:
If change issue yarn.lock to
server will not be broken by emacs file lock I also find
get different react-script under node_modules, |
I am facing this too. I do not wish to edit webpackDevserver.config.js on every project, nor do I wish to edit anything in node_modules, which is clearly meant to be ephemeral, deletable, reproducable, and isn't added to my git repo What I do want to do is edit using emacs, without having to break emacs by removing its locking files. I can confirm that @misapprehand's suggestion to change watchpack to version 1.6.0 seems to fix this issue... I wonder if this watchpack issue is related: webpack/watchpack#165 |
Edit: sorry. I didn't realised that there is already a workaround. I'm starting learning the react and found this annoying bug
to
I found some changelog in node_modules/chokidar/README.md
works fine for me now. |
Relevant: preactjs/preact-cli#1189 |
I have run into this same issue. I'm a little surprised that it seems so hard to fix. While the work around solutions are OK for immediate fix, they are a poor solution. Editing files in node_moduels/react-scripts/config is a hack. Strikes me the problem here is hiding configuration settings from the end user by burying them inside the package and not providing a way for the user to override/set them themselves. Some values can be over ridden with a .env file .e.g BROWSER, REACT_EDITOR, FAST_REFRESH, but others, like watchOptions cannot. What would be good is the ability to have support for a webpack.json and webpackDevServer.json files which the user could place in the root of their project and which would be read in and merged into the configuration objects returned, allowing easy override of defaults by end user. At least then, when we do an npm update and the react-scripts package is updated, we won't lose our settings and we can easily commit our preferences etc. |
At least when using create-react-app, you can install craco and use the following to set the ignore without having to eject or edit anything in
|
…hem in file watcher. closes facebook#9056
Is there any general fix for this, that does not require:
? The issue is open for already almost a year. If I understand correctly, the issue lies within some kind of "watcher", be it brocoli or craco or whatever. Shouldn't a watcher be configurable, instead of blindly tracking every single file in the directory? |
@ZelphirKaltstahl All we need is this PR to be accepted: #10706 |
Thanks for reminding me of this open PR. I/Someone need to add tests for it to be accepted I suppose. I don't have time at the moment. |
I just tested this by applying the patch to |
This patch works well for me. |
…hem in file watcher. closes facebook#9056
Hi, I just pushed another fix to #10706 . The merge request should be accepted if the GitHub Workflows succeeds. |
Those lock files breaks the auto refresh of the npm (or yarn, Idk yet), this solution was suggested in this post facebook/create-react-app#9056
…hem in file watcher. closes facebook#9056
Describe the bug
When running the development server using
npm start
, it throws an error and exits whenever a src file is edited in emacs. Emacs creates a file lock in the same directory as the file being edited. The file lock is a symlink to a non-existant file that has the same name as the file being edited, except it is preprended with.#
. The server sees this file, tries to compile it and throws an error because the file doesn't actually exist.In
babel.config.json
I haveand in
tsconfig.json
I havewhich is the default generated by create-react-app with the exception of the
exclude
option. Both theignore
andexclude
options have no affect.Did you try recovering your dependencies?
I still see the issue.
Which terms did you search for in User Guide?
I searched the docs and issues for problems created by lock files and how to exclude files from building. I also searched the docs for typescript and babel.
Environment
Steps to reproduce
create-react-app
.npm start
.ts
/tsx
fileExpected behavior
I expect the tool to either ignore the lock files because they aren't being imported by anything or to honor the rules in
tsconfig.json
orbabel.config.json
. Before migrating tocreate-react-app
I was using just webpack and typescript for development/bundling and there were no issues with emacs lock files.Actual behavior
The dev server starts properly and compiles the project fine, but once a source file is edited it throws an error and exits.
Reproducible demo
The text was updated successfully, but these errors were encountered: