parcel-plugin-asset-copier icon indicating copy to clipboard operation
parcel-plugin-asset-copier copied to clipboard

package.json not found

Open simonmnt opened this issue 4 years ago • 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

simonmnt avatar Sep 01 '20 10:09 simonmnt

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

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

issue-label-bot[bot] avatar Sep 01 '20 10:09 issue-label-bot[bot]

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

frankjoke avatar Jan 05 '21 15:01 frankjoke

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.

BrianRosamilia avatar Jan 05 '21 15:01 BrianRosamilia

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!

frankjoke avatar Jan 26 '21 20:01 frankjoke

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.

frankjoke avatar Jan 26 '21 21:01 frankjoke