ipfs / helia

An implementation of IPFS in JavaScript
https://helia.io
Other
812 stars 81 forks source link

Parcel cannot resolve Helia and any @helia/x packages #481

Closed minqianlu closed 3 months ago

minqianlu commented 3 months ago

When installing Helia into a Parcel-React project, Parcel doesn't seem able to resolve Helia or any of its related @helia/x packages.

I've created a mock project off of Parcel's official React example with the only change being importing helia and using it in App.jsx.

achingbrain commented 3 months ago

There are a few problems with your setup.

  1. You are using an outdated version of parcel - it’s was renamed from parcel-bundler to just parcel a few years ago - see the deprecation notice on https://www.npmjs.com/package/parcel-bundler and the migration guide https://parceljs.org/getting-started/migration
  2. Remove "main": "src/index.html" from package.json
  3. Add "type": "module" to package.json
  4. Add to to package.json:
    "@parcel/resolver-default": {
      "packageExports": true
    }
  5. Add type="module" to the script tag in src/index.html

It works for me with these changes.

Please do take a closer look at the parcel example at https://github.com/ipfs-examples/helia-parcel - it shows how to get it working

minqianlu commented 3 months ago

Perfect, thank you @achingbrain.