Parcel: Parcel can't watch files

Created on 6 May 2018  ยท  10Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› 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

Bug

Most helpful comment

@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.

All 10 comments

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

@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

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

@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.

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)

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

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

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:

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

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 ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Niggler picture Niggler  ยท  3Comments

donaldallen picture donaldallen  ยท  3Comments

davidnagli picture davidnagli  ยท  3Comments

mnn picture mnn  ยท  3Comments

jsftw86 picture jsftw86  ยท  3Comments