parcel: Cannot read property 'type' of undefined

šŸ› bug report

I have a small VueJS project. I am running ā€œparcel watch index.html --log-level 4 --out-dir wwwrootā€ from npm. On version 1.11.0 it would stop reacting to file changes after a few saves. I updated to version 1.12.0 and the same thing is happening but now I get an error (see below).

Note: I downgraded to parcel version 1.10.3 and everything works as expected when watching.

šŸŽ› Configuration (.babelrc, package.json, cli command)

{
  "name": "abs-setup",
  "description": "ABS Setup",
  "author": "Wayne Hiller",
  "scripts": {
    "dev": "parcel watch index.html --log-level 4 --out-dir wwwroot",
    "build": "parcel build index.html --out-dir wwwroot",
    "publish": "npm run build && del-cli bin/Release/netcoreapp2.2/publish && dotnet publish -c Release /p:PublishProfile=Properties\\\\PublishProfiles\\\\FolderProfile.pubxml"
  },
  "devDependencies": {
    "@aspnet/signalr": "1.1.2",
    "@babel/core": "7.3.4",
    "@babel/preset-env": "7.3.4",
    "@vue/component-compiler-utils": "^2.6.0",
    "axios": "0.18.0",
    "bootstrap": "4.3.1",
    "bootstrap-vue": "2.0.0-rc.11",
    "less": "^3.9.0",
    "parcel-bundler": "1.12.0",
    "parcel-plugin-clean-easy": "1.0.2",
    "vue": "2.6.7",
    "vue-axios": "2.1.4",
    "vue-template-compiler": "^2.6.7",
    "del-cli": "1.1.0"
  },
  "dependencies": {
    "vue-hot-reload-api": "^2.3.3"
  },
  "parcelCleanPaths": [
    "wwwroot/*.*",
    "wwwroot/debug"
  ]
}

šŸ¤” Expected Behavior

No error

😯 Current Behavior

Error being generated after 5 or 6 saves of the same .vue file.

[12:13:38 PM]: Ɨ Cannot read property 'type' of undefined [12:13:38 PM]: at Bundler.createBundleTree (E:\Development\AIN 2\ABS\Setup\ABS Setup\node_modules\parcel-bundler\src\Bundler.js:652:54) at Bundler.createBundleTree (E:\Development\AIN 2\ABS\Setup\ABS Setup\node_modules\parcel-bundler\src\Bundler.js:719:12) at Bundler.createBundleTree (E:\Development\AIN 2\ABS\Setup\ABS Setup\node_modules\parcel-bundler\src\Bundler.js:719:12) at Bundler.bundle (E:\Development\AIN 2\ABS\Setup\ABS Setup\node_modules\parcel-bundler\src\Bundler.js:298:14) at process._tickCallback (internal/process/next_tick.js:68:7)

šŸŒ Your Environment

Software Version(s)
Parcel 1.12.0
Node 10.15.2
npm/Yarn 6.9.0
Operating System Win 10 x64

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 13
  • Comments: 60 (5 by maintainers)

Most upvoted comments

I solved this issue thanks to #2716 and https://parceljs.org/hmr.html#safe-write ! Unfortunately I missed it. Sorry šŸ˜„

FYI, we’re working on a new watcher for Parcel 2 which should be much more reliable. https://github.com/parcel-bundler/watcher

This still happens in vim with backupcopy=yes and with all plugins disabled. šŸ™ˆ 😬

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 18 2019 20:13:57)
macOS version
Included patches: 1-1550
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     +perl              -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           -python            +visual
+cmdline_info      +libcall           +python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          +ruby              +wildmenu
+cursorbind        +lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      -sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        -xsmp
+emacs_tags        -mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary
+extra_search      +mouse_sgr         -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6

I have had this problem as well but I am using linux/vi and other editors, as pointed out it is a known problem see bug #2716 and https://parceljs.org/hmr.html#safe-write where problem is described along with out to turn of the auto write features off tools such as WebStorm etc are described.

FWIW perhaps another cause resulting in the same error message, but in my case removing the .cache directory helped.

@JonathanDn If you are going to comment on an existing issue, on any project, open source or otherwise, then you should at least take the time to read the thread. As was the case here, being too lazy to read a thread makes it very likely that you will miss out on crucial information that could help you solve the problem yourself. No one is expecting you to read every issue in the project, but if one applies to you, do yourself a favor and read it.

By reading it, you might have also understood that the file watcher in V1 could not be fixed for this particular issue because it would be a breaking change, so the developers opted to include the fix in the forthcoming V2. Considering it can be easily worked around, this is a very reasonable decision.

It took me less than 20 minutes to read this thread, understand the problem, and find a workaround for my IDE, helped in part by those who commented before me with workarounds for their IDEs. That’s a small price to pay and now Parcel is working great for me. I imagine you spent a whole lot more time porting to Webpack…

I do think it’s important that the Parcel team be empathetic and sensitive here when it comes to unfixed bugs. I use VS Code on a Mac, and I’ve run into this bug when deleting files, among other things. It’s definitely a bug, and the Parcel team has communicated they aren’t really fixing bugs in v1, and that has a real impact, putting loyal users in a tough position. (I hold space for your pain, loyal users!) However, the good news is that Parcel 2 is on the way.

We do fix critical bugs, most bugs in Parcel 1 have been fixed. This one we couldn’t really fix without a new watcher… Which is a breaking change semver wise anyway… So releasing a fix in Parcel 2 seems like a logical choice

Nine out of ten engineers already think everyone should just use webpack

Pretty sure a lot of devs wanna get rid of webpack sooner than later…

I want my engineering team to use Parcel, but the fact that it can’t correctly watch globs is becoming a problem. I’m tempted to try Parcel 2 to see if it doesn’t have bugs so large as ā€œcrashes if you add and move files,ā€ but I’m not sure how hopeful to be, since it’s alpha, and apparently there is a brand-new file watcher?

I’m totally the kind of programmer who would turn up my nose at existing file-watchers and write my own, but existing file-watchers are decent IMO, and the fact that this bug was never fixed, and probably will never be fixed, doesn’t give me a ton of confidence in the Parcel team, meaning I wonder if they should be writing a file watcher or just working on shipping reasonably non-buggy software? Will the bugs be fixed, this time, in Parcel 2, or will the team immediately start working on Parcel 3?

I just had to vent some skepticism and frustration there. My lack of faith in the Parcel team may be totally unfounded.

Are we any closer to being able to test out parcel 2 with the new watcher yet?

I have the exact same issue. createBundleTree calls bundle.findCommonAncestor, which returns undefined. The while loop condition in findCommonAncestor fails immediately because a !== b, so last is undefined and returned.

The things worked with this version: chalk 4.1.2

I had the same issue.

I happened to do the same when git hook. The solution was to drop lint-staged version from 10 -> 7.

On win 10 using vim backupcopy=yes solved it for me!

I am experiencing the same bug, I’m also on x64 Windows 10 and I’m using Visual Studio 2017. I can’t reproduce the bug when using another text editor, so it seems to be related to VS 2017.

So I copied html5boilerplate [ https://github.com/h5bp/html5-boilerplate ] for something and install/run this without any change. It opened up on my browser just fine.

Left the PC running as it is. Come back after 30 minutes.

yarn run v1.22.5
$ parcel index.html --open
Server running at http://localhost:1234 
Cannot read property 'type' of undefined
    at Bundler.createBundleTree (/home/ubuntu/<snip>/node_modules/parcel-bundler/src/Bundler.js:654:54)
    at Bundler.createBundleTree (/home/ubuntu/<snip>/node_modules/parcel-bundler/src/Bundler.js:721:12)
    at Bundler.createBundleTree (/home/ubuntu/<snip>/node_modules/parcel-bundler/src/Bundler.js:721:12)
    at Bundler.bundle (/home/ubuntu/<snip>/node_modules/parcel-bundler/src/Bundler.js:298:14)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Like how…?

There’s just one dependency:

  "devDependencies": {
    "parcel-bundler": "^1.12.4"
  }

I’m having the same problem on Codeanywhere, I’m going to check if updating to Parcel 2 beta solves this.

this has been the solution for me - updating to the next parcel version. parcel 2 seems much better and faster anyway; everything works the same.

@devongovett Its wonderful that your working on a new watcher. I do not see any ETA for that.

I am using webstorm and still experience this broken watch issue all the time. Any temp fix??

Disabling backupcopy worked for me as well ( ubuntu 18 ), however I don’t want to disable backups. Setting a new backupdir worked by adding the following lines to my .vimrc

set backupdir=~/misc

You can find more info on backups with :help backup

Thanks for the tip. Putting set backupcopy=yes in my .vimrc also fixed the errors for me. (neovim on ubuntu 16.04)