7

After I've deleted couple files from project that uses Parcel bundler, command parcel ./index.html started to output following error:

Cannot read property 'type' of undefined
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:654:54)
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
at Bundler.bundle (<project_root>/node_modules/parcel-bundler/src/Bundler.js:298:14)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)

3 Answers 3

18

Solution

Delete .parcel-cache and dist folders and run command again. (NB: The cache folder was called just .cache in version 1.x of Parcel.)

Proposal

Add cleanup script for this and run it each time before parcel build:

 "scripts": {
   "cleanup": "rm -rf .parcel-cache dist",
   "dev": "npm run cleanup && parcel ./index.html",
   ...
 }

Also you can use rimraf lib to do a crossplatform cleanup task. https://www.npmjs.com/package/rimraf. So scripts will look like this:

 "scripts": {
   "cleanup": "rimraf .parcel-cache dist",
   "dev": "npm run cleanup && parcel ./index.html",
   ...
 }
2

Above answer works for linux OS, if you are using windows OS rename your npm scripts as following

"scripts": {
"cleanup": "rmdir /q /s .parcel-cache dist",
"start": "npm run cleanup && parcel src/index.html"
}
0

Try this on Windows:

"scripts": {
    "cleanup": "rmdir /q /s .parcel-cache dist || echo 'no cached files'",
    "start": "yarn run cleanup && parcel src/index.html"
}

The solution of "lakshan perera" did not work for me so I enhanced it.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.