After I’ve deleted couple files from project that uses Parcel bundler, command parcel ./index.html
started to output following error:
JavaScript
x
11
11
1
Cannot read property 'type' of undefined
2
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:654:54)
3
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
4
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
5
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
6
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
7
at Bundler.createBundleTree (<project_root>/node_modules/parcel-bundler/src/Bundler.js:721:12)
8
at Bundler.bundle (<project_root>/node_modules/parcel-bundler/src/Bundler.js:298:14)
9
at <anonymous>
10
at process._tickCallback (internal/process/next_tick.js:189:7)
11
Advertisement
Answer
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:
JavaScript
1
6
1
"scripts": {
2
"cleanup": "rm -rf .parcel-cache dist",
3
"dev": "npm run cleanup && parcel ./index.html",
4
5
}
6
Also you can use rimraf lib to do a crossplatform cleanup task. https://www.npmjs.com/package/rimraf. So scripts will look like this:
JavaScript
1
6
1
"scripts": {
2
"cleanup": "rimraf .parcel-cache dist",
3
"dev": "npm run cleanup && parcel ./index.html",
4
5
}
6