tiaanduplessis/parcel-plugin-asset-copier

package.json not found

simonmnt opened this issue · 5 comments

Hi, when I run parcel with javascript's entry, the plugin get an error.

parcel watch js/main.js
TypeError: Cannot read property 'getPackage' of null
    at Bundler.<anonymous> (/Users/simon/Documents/LAB/parcel/public/theme/skeleton/node_modules/parcel-plugin-asset-copier/index.js:19:87)
    at Bundler.emit (events.js:315:20)
    at Bundler.bundle (/Users/simon/.config/yarn/global/node_modules/parcel-bundler/src/Bundler.js:340:12)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
No package.json file found.

Regards

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.78. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

I have this issue as well. is there any solution or work around for that?

Hmm it's strange that it gives that error since obviously you must have a package.json (i think thats just a parcel error)

I'm pretty sure you messed up your parcel entrypoint. Try uninstalling this plugin and rerunning the same parcel command, it most likely cant find the entrypoint and is throwing that.

found it working as long as I run parcel on a file which is in the same directory than the package.json. As soon I run parcel on other file (like src/index,jsx) it does not work anymore.
The error seem to happen in parcel-plugin-asset-copier\index.js:19:87
He seem to look for the entry of assets and cannot find them because package.json is not in the same directory!

Ok, I changed `try {

    const bundle = bundler.mainBundle.childBundles.values().next().value;

    if (bundle && bundle.entryAsset) {

      pkg = await bundle.entryAsset.getPackage()

    } else {

      pkg = await bundler.mainBundle.entryAsset.getPackage()

    }

` in parcel-plugin-asset-copier\index.js and it's working now.