Parcel: @parcel/packager-html: Asset has no content

Created on 3 Nov 2020  ยท  8Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report

After migrating from Parcel 1 (which had no errors),

parcel build ./html/prsm.html --public-url .

fails with Asset has no content error.

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

parcel build ./html/prsm.html --public-url .

no .parcelrc

./html/prsm.html has 667 lines of HTML, including links to js modules

๐Ÿค” Expected Behavior

Successful bundling, as with Parcel 1

๐Ÿ˜ฏ Current Behavior

Fails with

๐Ÿšจ Build failed.
@parcel/packager-html: Asset has no content
Error: Asset has no content
    at CommittedAsset.getContent (/Users/scs1ng/Sites/prsm/node_modules/@parcel/core/lib/CommittedAsset.js:99:15)
    at CommittedAsset.getCode (/Users/scs1ng/Sites/prsm/node_modules/@parcel/core/lib/CommittedAsset.js:107:30)
    at Asset.getCode (/Users/scs1ng/Sites/prsm/node_modules/@parcel/core/lib/public/Asset.js:204:48)
    at /Users/scs1ng/Sites/prsm/node_modules/@parcel/packager-css/lib/CSSPackager.js:77:51
    at /Users/scs1ng/Sites/prsm/node_modules/@parcel/utils/lib/PromiseQueue.js:53:30
    at PromiseQueue._runFn (/Users/scs1ng/Sites/prsm/node_modules/@parcel/utils/lib/PromiseQueue.js:106:13)
    at PromiseQueue._next (/Users/scs1ng/Sites/prsm/node_modules/@parcel/utils/lib/PromiseQueue.js:93:16)
    at PromiseQueue.run (/Users/scs1ng/Sites/prsm/node_modules/@parcel/utils/lib/PromiseQueue.js:84:12)
    at Object.package (/Users/scs1ng/Sites/prsm/node_modules/@parcel/packager-css/lib/CSSPackager.js:86:31)
    at PackagerRunner.package (/Users/scs1ng/Sites/prsm/node_modules/@parcel/core/lib/PackagerRunner.js:346:27)

๐Ÿ’ Possible Solution

Don't know

๐Ÿ”ฆ Context

๐Ÿ’ป Code Sample

package.json (extract):

"scripts": {
        "lint": "./node_modules/.bin/eslint ./js/*.js --fix --quiet",
        "pretty": "prettier --write ./html/*.html ./*.html ./js/*.js ./css/prsm.css doc/**/*.{html,css} package.json",
        "dev": "parcel ./html/prsm.html",
        "build1": "parcel build ./html/prsm.html --public-url . ",
        "clean": "rm -rf dist/* out/*"
    },
    "dependencies": {
        "@egjs/hammerjs": "^2.0.17",
        "@joeattardi/emoji-button": "^2.12.1",
        "component-emitter": "^1.3.0",
        "fast-xml-parser": "^3.17.4",
        "foodoc": "0.0.9",
        "hammerjs": "^2.0.8",
        "keycharm": "^0.3.1",
        "moment": "^2.29.1",
        "timsort": "^0.3.0",
        "uuid": "^7.0.3",
        "vis-data": "^6.6.1",
        "vis-network": "^7.10.2",
        "vis-util": "^4.3.4",
        "y-indexeddb": "^9.0.5",
        "y-websocket": "^1.3.6",
        "yjs": "^13.4.2"
    },
    "devDependencies": {
        "eslint": "^6.8.0",
        "eslint-config-prettier": "^6.15.0",
        "jsdoc": "^3.6.6",
        "parcel": "^2.0.0-nightly.438",
        "prettier": "2.0.5"
    },

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-nightly.440
| Node | v14.15.0
| npm/Yarn | 6.14.8
| Operating System | 10.15.7

Bug โœจ Parcel 2 ๐Ÿ’ฐ Cache

Most helpful comment

Yeah! Deleting .parcel-cache/ did the trick - works now.

All 8 comments

Does this happen even after deleting the .parcel-cache folder?

Yeah! Deleting .parcel-cache/ did the trick - works now.

I was too hasty. Indeed, deleting .parcel-cache allows the build to proceed successfully. But the same @parcel/packager-html: Asset has no content problem reappears the second time I build (clearing the cache again allows the build to succeed). Are there further diagnostics it would be helpful to see to track down what is wrong?

I'd like to confirm that I'm experiencing the exact same symptoms (with the latest nightly version of Parceljs). If I delete my .parcel-cache folder, the error goes away, but as soon as I edit the index.html file that's being watched/built, the error reappears, forcing me to delete the .parcel-cache folder again.

Editing the SCSS or JS files that are linked in de html-file does not trigger this error and the files get built as expected.

These are the scripts in my package.json file:

  "scripts": {
    "dev": "parcel src/index.html",
    "build": "parcel build src/index.html --public-url . --no-cache",
    "preparcel": "rm -rf dist/",
    "prebuild": "rm -rf dist/",
    "postbuild": "cp -r static/* dist/"
  }

Can someone provide a code sample for reproduction for this error?

The problem continues to occur, apparently intermittently (i.e. I haven't worked out what does or does not provoke it). You can try to reproduce it by cloning https://github.com/micrology/prsm.git and running npm install and npm run dev

I got same error but removing .parcel-cache is helped.

I faced with this issue during attempting to run Element Plus
https://github.com/bubnenkoff/element-plus-parcel2-error.git

$ npm run start

> [email protected] start F:\code\fas_2020\cat_front_v2
> parcel serve ./public/index.html

โ„น Server running at http://localhost:1234
Bundling...
Packaging index.[hash].js...
ร— Build failed.
@parcel/packager-js: Asset has no content
Error: Asset has no content
    at CommittedAsset.getContent (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\core\lib\CommittedAsset.js:99:15)
    at CommittedAsset.getCode (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\core\lib\CommittedAsset.js:107:30)
    at Asset.getCode (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\core\lib\public\Asset.js:204:48)
    at F:\code\fas_2020\cat_front_v2\node_modules\@parcel\packager-js\lib\JSPackager.js:197:65
    at F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:53:30
    at PromiseQueue._runFn (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:106:13)
    at PromiseQueue._next (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:93:16)
    at PromiseQueue._next (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:96:12)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
console: (node:10036) UnhandledPromiseRejectionWarning: Error: Asset has no content
    at CommittedAsset.getContent (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\core\lib\CommittedAsset.js:99:15)
    at CommittedAsset.getCode (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\core\lib\CommittedAsset.js:107:30)
    at Asset.getCode (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\core\lib\public\Asset.js:204:48)
    at F:\code\fas_2020\cat_front_v2\node_modules\@parcel\packager-js\lib\JSPackager.js:197:65
    at F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:53:30
    at PromiseQueue._runFn (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:106:13)
    at PromiseQueue._next (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:93:16)
    at PromiseQueue._next (F:\code\fas_2020\cat_front_v2\node_modules\@parcel\utils\lib\PromiseQueue.js:96:12)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
console: (node:10036) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
console: (node:10036) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipodev picture philipodev  ยท  3Comments

oliger picture oliger  ยท  3Comments

termhn picture termhn  ยท  3Comments

devongovett picture devongovett  ยท  3Comments

466023746 picture 466023746  ยท  3Comments