澳门银河网上官方赌场_老品牌值得信赖

ITKeyword,专注技术干货聚合推荐

注册 | 登录

解决javascript - webpack --watch isn't compiling changed files

itPublisher 分享于

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
地址https://www.aliyun.com/minisite/goods

I tried running webpack --watch and after editing my JS files, it doesn't trigger an auto-recompilation.

I've tried reinstalling webpack using npm uninstall but it's still not working.

Any ideas?

javascript webpack fsevents
|
  this question
edited Feb 19 '15 at 18:32 Ben Mosher 8,682 4 44 68 asked Nov 3 '14 at 5:17 alcedo 504 1 5 11

 | 

13 Answers
13

解决方法

FYI: it seems OS X can have a folder get corrupted and no longer send fsevents (which watchpack/chokidar/Finder uses) for itself and any child folders. I can't be sure this is what happened to you, but it was very frustrating for me and a colleague.

We were able to rename the corrupt parent folder and then watch events immediately came through as expected. See this blog post for more info: http://feedback.livereload.com/knowledgebase/articles/86239-os-x-fsevents-bug-may-prevent-monitoring-of-certai

The recommended fixes from the above link are:

  • rebooting the computer
  • checking the disk and repairing permissions via Disk Utility
  • adding the folder to Spotlight privacy list (the list of folders to not index), and then removing from it, effectively forcing a reindexing
  • renaming the folder, and then possibly renaming it back
  • re-creating the folder and moving the old contents back into it

First two did not work for us, didn't try the Spotlight suggestion, and the re-creation did not prove necessary.

We were able to find the root problem folder by opening Finder and creating files in each successive parent folder until one showed up immediately (since Finder will get hosed by this bug as well). The root-most folder that does not update is the culprit. We just mv'd it and mv'd it back to its original name, and then the watcher worked.

No idea what causes the corruption, but I'm just glad to have a fix.


|
  this answer
edited Feb 19 '15 at 18:31 answered Feb 19 '15 at 15:24 Ben Mosher 8,682 4 44 68 2   I renamed my ~/Sites folder to something else, and then back to ~/Sites and it fixed the error. It also has fixed several other errors on other projects. Talk about killing 2 birds with 1 stone. Thank you so much!!! –  Kirk May 18 '15 at 21:09      I faced this issue while working with watchify, none of the steps worked with me so I ended up using poll arg. A lot of people are passing the poll arg to browserify instead of watchify. My code looks like: watchify(browserify(config.src,{}), {poll:100}); –  Ayman Jun 4 '15 at 15:59      Not 100% sure this is the reason, but turning off my Dropbox sync client while trying to run watchify worked for me. Both running npm install as well as renaming a directory are very intensive operations the way the sync client is implemented. –  Z1MM32M4N Aug 9 '15 at 0:13      Restarting worked for me on Linux, I had this issue with webpack-dev-server, after hours of trying to work out why it was working yesterday but not today... –  DomA Aug 19 '15 at 13:30      IIRC, webpack-dev-server's watcher has a poll option that should mitigate the issue if it is recurring. My team often has the issue repeatedly crop up. Still not sure what's causing it. –  Ben Mosher Aug 19 '15 at 17:03  |  show more comments

If your code isn't being recompiled, try increasing the number of watchers (in Ubuntu):

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Source: https://webpack.github.io/docs/troubleshooting.html


|
  this answer
answered Nov 5 '15 at 6:07 César 410 3 6      sudo sysctl -p does not work on Mavericks. Any new ideas? –  Simon H Mar 3 '16 at 6:46      solved for my Fedora –  spirinvladimir Jul 18 '16 at 6:45      Worked for me (Ubuntu), thanks ;) –  Bernardo Feb 6 at 13:58

 | 

I have had this problem when working with WebStorm.

Disabling Settings -> System Settings -> "safe write" resolved it for me.

Found the recommendation to do so in: WebPack Troubleshooting


|
  this answer
answered Nov 17 '16 at 21:52 Chris 1,563 13 29

 | 

Just to add to possible solutions: I had my project folder inside a Dropbox folder, moving it out solved the problem for me. (OS X)


|
  this answer
answered Jan 29 '16 at 3:58 Les 2,246 12 15      This worked for me as well—I wish this answer had been closer to the top. OS X for me as well (El Capitan). –  natchiketa Feb 4 '16 at 23:11      This fixed my issue as well. Thanks for that! –  Federico Jun 17 '16 at 5:17 1   Do you know why is happening this? @Les –  Ekaitz Hernandez Troyas Nov 24 '16 at 16:39

 | 

One issue is that if your path names aren't absolute then things like this will happen. I had accidentally set resolve.root to ./ instead of __dirname and this caused me to waste a lot of time deleting and re-creating files like the guys above me.


|
  this answer
answered Mar 8 '15 at 3:54 Liam Horne 568 4 13

 | 

If you are using Vim you should try setting backupcopy to yes rather than the default auto. Otherwise Vim will sometimes rename the original file and create a new one, which will mess up with webpack watch:

https://github.com/webpack/webpack/issues/781

Just add this to your vim settings if this is the case:

set backupcopy=yes


|
  this answer
answered Feb 23 '16 at 17:13 rosenfeld 1,203 12 12

 | 

If changing fs.inotify.max_user_watches as pointend out by César still doesn't work try to use polling instead of native watchers by creating your script as shown in the docs or running webpack with --watch --watch-poll options.


|
  this answer
answered Apr 5 '16 at 23:34 Angelo Selvini 51 1 3

 | 

Updates: deleting the entire directory and git cloning afresh from repo fixes my problem.


|
  this answer
answered Nov 3 '14 at 5:40 alcedo 504 1 5 11

 | 

Possible solution: changing context to the app directory.

I had all my webpack config files in a sub folder:

components/
webpack/
 development.js
app.js

In webpack/development.js, set context: path.join(__dirname, '../') solved my problem.


|
  this answer
answered Dec 24 '16 at 15:36 wwayne 55 6

 | 

After trying a handful of strategies for fixing this problem I ended up just giving up but then while solving another issue I tried again and all of sudden the --watch flag was finally working.

To be honest I do not know what specifically made it work but after performing the following steps it just started working:

1. Install most recent gcc version
$ sudo port install gcc48
$ sudo port select --set gcc mp-gcc48

2. Install most recent clang version
$ sudo port install clang-3.6
$ sudo port select --set clang mp-clang-3.6

3. Export variables holding the patch to C and C++ compiler
$ export CC=/opt/local/bin/clang
$ export CXX=/opt/local/bin/clang++

It might have happened that while installing these packages some dependency just added the missing piece of the puzzle, who knows ...

Hope this help anyone struggling out there to make it working.


|
  this answer
answered Jan 3 at 22:34 utxeee 338 4 15

 | 

Note that if you run webpack within a virtual machine (Vagrant / Virtualbox) and you change your files on the host platform, file updates in the
 d folder may not trigger inotify on Ubuntu. That will cause the changes to not be picked up by webpack.

see: Virtualbox ticket #10660

In my case, editing and saving the file on de guest (in vi) did trigger webpack. Editing it on the host (in PhpStorm, Notepad or any other application) dit NOT trigger webpack whatever I did.

I solved it by using vagrant-fsnotify.


|
  this answer
answered Feb 7 at 19:44 mk8374876 1

 |  -1

An easy solution on MacOS is the following :

Open two terminal windows in the same directory that your project resides.

In the first terminal window run : webpack --watch

In the second terminal windows run : webpack-dev-server

I have tried many possible solutions and this seems to be the most reliable


|
  this answer
answered Oct 2 '16 at 22:51 skiabox 1,486 5 47 74      PS: I am using Mac OS Sierra. –  skiabox Oct 3 '16 at 13:53      Any reason for the down vote? –  skiabox Oct 24 '16 at 15:00

 |  -3

Yo!!!! Folder case sensitivity was my issue. My code calls to require() had all lowercase path names BUT the actually directories had an uppercase letter in them. I renamed all my directories to lowercase and webpack watching worked instantly. YESssssssssssssss!!!!! _AckerApple


|
  this answer
answered Mar 24 '16 at 15:34 Acker Apple 15

 | 


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。

澳门银河网上官方赌场 <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <文本链> <文本链> <文本链> <文本链> <文本链> <文本链>