Now that 1.5 switched to new watcher by default, I noticed it’s using a lot of CPU all the time:
It’s not a Gulp issue because it goes away if I use OldWatchingPlugin
.
It’s also not related to compilation because it happens when Webpack is idle as well.
Any ideas?
OS X 10.10.1
It doesn’t seem to lag so much if I explicitly install
fsevents
so chokidar uses it.Still, it’s about 150%% and doesn’t get lower.
OK, let’s presume I did something stupid.
Nuking
node_modules/webpack
andnpm install
fixed the problem.Still—I wonder if Watchpack (and Webpack) should now have
fsevents
as an optional dependency?Otherwise it just doesn’t get installed by default (even if it could be).
Or is this not how NPM works?
In case this helps someone else, I was able to fix high CPU usage by doing what gaearon suggested in a previous comment.
I had restored a Time Machine backup from Laptop A, on which I previously ran
npm install
, to Laptop B.On Laptop B, deleting
node_modules/
and runningnpm install
brought CPU usage from ~45%% down to 0%%.OS X 10.11.3 (on both laptops).
I just ran into this too. You don’t need to run
npm install
on your whole project again. Justnpm install fsevents
in the project directory.Facing the same issue but on Windows 10, and I can’t install fsevents, it’s an OS X-only module…
edit: ignoring node_modules solved it for me
@gaearon I’m sorry for dusturbing. I’ve just found out the cause of my problem and it doesn’t relate to this topic. The reason it consumed so much CPU was in these lines:
I haven’t even seen what they do in docs as the most of the config came from
angular2-webpack-starter
project. Commenting the lines solves the problem.In my experience, this CPU hogging happens every time I upgrade node.js to a new version, I need to reinstall
fsevents
(or just nuke thenode_modules
folder and reinstall)@ngyikp in that case, you just need
npm rebuild
.If you use yarn you can do
yarn add fsevents --optional
. This will allow you to savefsevents
inpackage.json
but it will not break builds on other platforms.I should keep a note for
npm rebuild
Deleting the entire node_modules folder and
npm install
fixed the problem for me. Just nuking the webpack folder did not do the trick.Solved by simply running
npm install fsevents
150%% in watch mode using webpack 4.17.2.
The fsevents fix did not work for me, but this did:
https://webpack.js.org/configuration/watch/#watchoptions-ignored