Skip to content
Advertisement

Parcel bundler “ENOENT: no such file or directory” when delete files from project

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)

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:

 "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",
   ...
 }
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement