parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.37k stars 2.27k forks source link

Parcel can't watch files #1308

Closed WesleiRamos closed 6 years ago

WesleiRamos commented 6 years ago

🐛 bug report

Parcel can't watch files on windows

🎛 Configuration (.babelrc, package.json, cli command)

> cd "c:\my project folder"
> parcel

🤔 Expected Behavior

Watch files

😯 Current Behavior

Server running at http://localhost:1234
∞  Building bundle-url.js...
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, watch 'C:\Users\Weslei\AppData\Local\Microsoft\Windows\Temporary Internet Files'
    at FSWatcher.start (fs.js:1375:26)
    at Object.fs.watch (fs.js:1412:11)
    at createFsWatchInstance (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:37:15)
    at setFsWatchListener (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:229:14)
    at FSWatcher.NodeFsHandler._handleDir (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:408:19)
    at FSWatcher.<anonymous> (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:456:19)
    at FSWatcher.<anonymous> (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:461:16)
    at FSReqWrap.oncomplete (fs.js:150:5)
Emitted 'error' event at:
    at FSWatcher._handleError (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\index.js:260:10)
    at createFsWatchInstance (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:39:5)
    at setFsWatchListener (C:\Users\Weslei\AppData\Local\Yarn\config\global\node_modules\chokidar\lib\nodefs-handler.js:80:15)
    [... lines matching original stack trace ...]
    at FSReqWrap.oncomplete (fs.js:150:5)

💁 Possible Solution

Adding ignorePermissionErrors: true in new FSWatcher (Watcher.js) seems to solve the problem.

🔦 Context

This problem appeared after upgrading from version 1.6.1 to 1.8.1

🌍 Your Environment

Software Version(s)
Parcel 1.8.1
Node 10.0.0
npm/Yarn yarn 1.6.0
Operating System Windows 10
mischnic commented 6 years ago

Does parcel index.html work? (See https://parceljs.org/getting_started.html)

WesleiRamos commented 6 years ago

@mischnic the same error appears, adding ignorePermissionErrors: true the error no longer appears, but the build time gets extremely large, I waited 3 minutes and did not build (consumed 400mb of memory for a "hello world" with vue)

Edit: I've downgraded to 1.7.1 and it's working fine

eduardbadillo commented 6 years ago

In case it helps, I would like to add:

🎛 Configuration (.babelrc, package.json, cli command)

Command:

npx parcel watch src/main.js --public-url /static/ --hmr-hostname=localhost --hmr-port=35730

.babelrc

{  "plugins": [    "transform-object-rest-spread"  ]}

package.json

"devDependencies": {
    "@vue/component-compiler-utils": "^1.2.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "parcel-bundler": "^1.7.1",
    "pug": "^2.0.3",
    "stylus": "^0.54.5",
    "vue-template-compiler": "^2.5.16"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "md5": "^2.2.1",
    "mousetrap": "^1.6.1",
    "vue": "^2.5.16",
    "vue-hot-reload-api": "^2.3.0",
    "vuetify": "^1.0.13",
    "vuex": "^3.0.1"
  }
events.js:165
      throw er; // Unhandled 'error' event
      ^

Error: watch /app/node_modules/babel-preset-env/node_modules/browserslist/README.md ENOSPC
    at FSWatcher.start (fs.js:1409:19)
    at Object.fs.watch (fs.js:1435:11)
    at createFsWatchInstance (/app/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/app/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/app/node_modules/chokidar/lib/nodefs-handler.js:229:14)
    at FSWatcher.NodeFsHandler._handleFile (/app/node_modules/chokidar/lib/nodefs-handler.js:256:21)
    at FSWatcher.<anonymous> (/app/node_modules/chokidar/lib/nodefs-handler.js:474:21)
    at FSReqWrap.oncomplete (fs.js:171:5)
Emitted 'error' event at:
    at FSWatcher._handleError (/app/node_modules/chokidar/index.js:260:10)
    at createFsWatchInstance (/app/node_modules/chokidar/lib/nodefs-handler.js:39:5)
    at setFsWatchListener (/app/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    [... lines matching original stack trace ...]
    at FSReqWrap.oncomplete (fs.js:171:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

🔦 Context

This is happening to my coworkers in a docker container, in an Ubuntu VM. The problem appeared after upgrading to 1.8.1 from 1.7.1.

I'm running the same container on a Win10, docker-ce 18.03.1 and I have no problems with the latest version of parcel.

Software Version(s)
Parcel 1.8.1
Node 9.11.1
npm/Yarn npm 5.6.0
Operating System Alpine 3.6.2 (Docker image node:alpine)
Docker version 17.05-ce running on Ubuntu 16.04
ranfdev commented 6 years ago

@eduardbadillo i have your same problem Quick fix for every linux distro: sysctl fs.inotify.max_user_watches=60000 (you must run this as root) This fix is temporary. If you want, you can make this permanent.

dobesv commented 6 years ago

It seems like it might be watching files that it shouldn't.

$ /home/ubuntu/parcel-bug-css/node_modules/.bin/parcel watch index.html
⏳  Building bundle-url.js...
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, watch '/home/ubuntu/.gvfs'
    at FSWatcher.start (fs.js:1375:26)
    at Object.fs.watch (fs.js:1412:11)
    at createFsWatchInstance (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:229:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:408:19)
    at FSWatcher.<anonymous> (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:456:19)
    at FSWatcher.<anonymous> (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:461:16)
    at FSReqWrap.oncomplete (fs.js:150:5)
Emitted 'error' event at:
    at FSWatcher._handleError (/home/ubuntu/parcel-bug-css/node_modules/chokidar/index.js:260:10)
    at createFsWatchInstance (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:39:5)
    at setFsWatchListener (/home/ubuntu/parcel-bug-css/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    [... lines matching original stack trace ...]
    at FSReqWrap.oncomplete (fs.js:150:5)
elldritch commented 6 years ago

I think it's trying to watch every file under node_modules, which causes it to quickly hit the inotify limit.

goliney commented 6 years ago

Quick fix for every linux distro: sysctl fs.inotify.max_user_watches=60000 (you must run this as root)

It solved the problem for me. Thanks @ranfdev

nicoandresr commented 6 years ago

why this issue was closed? :thinking: I got the same behavior with Parcel 1.9.2 😿 And although the quick fix of @ranfdev works I believe that this not is the definitive solution! :policeman:

ranfdev commented 6 years ago

@nicoandresr that's because parcel watches the entire node_modules folder. There are too many files in there. #1559 should fix this

rrousselGit commented 6 years ago

I would like to use docker during development; and ended up facing the same issue.

Files are correctly edited inside my container. But parcel just don't do anything. Most likely due to a watch fail.

Is there anything we can do here ?