Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when imported from ESM code #3

Closed
Macil opened this issue Jan 29, 2023 · 1 comment · Fixed by #4
Closed

Error when imported from ESM code #3

Macil opened this issue Jan 29, 2023 · 1 comment · Fixed by #4
Assignees
Labels
enhancement New feature or request

Comments

@Macil
Copy link

Macil commented Jan 29, 2023

If you try to import this library from ESM code, you get a fatal error:

% npm i @filebase/client
npm WARN deprecated multiaddr-to-uri@8.0.0: This module is deprecated, please upgrade to @multiformats/multiaddr-to-uri
npm WARN deprecated multiaddr@10.0.1: This module is deprecated, please upgrade to @multiformats/multiaddr

added 314 packages in 12s

29 packages are looking for funding
  run `npm fund` for details
% echo 'import { FilebaseClient } from "@filebase/client";' > foo.mjs
% node foo.mjs
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_INVALID_PACKAGE_CONFIG]: Invalid package config /private/tmp/bar/node_modules/ipfs-car/dist/esm/package.json while importing /private/tmp/bar/node_modules/ipfs-car/dist/esm/pack/index.js. Unexpected token ''', "'{ "type" "... is not valid JSON
    at new NodeError (node:internal/errors:399:5)
    at getPackageConfig (node:internal/modules/esm/package_config:64:11)
    at getPackageScopeConfig (node:internal/modules/esm/package_config:112:27)
    at getPackageType (node:internal/modules/esm/resolve:690:25)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:54:12)
    at defaultGetFormatWithoutErrors (node:internal/modules/esm/get_format:103:43)
    at defaultResolve (node:internal/modules/esm/resolve:1094:13)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:418:18) {
  code: 'ERR_INVALID_PACKAGE_CONFIG'
}

Node.js v19.5.0

I ran into this because the js-ipfs packages all went ESM last year and I was trying upgrading a project that depended on this library to use ESM to make it easier to use the latest js-ipfs packages.

@jtsmedley jtsmedley self-assigned this Jan 30, 2023
@jtsmedley jtsmedley added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jan 30, 2023
@jtsmedley
Copy link
Collaborator

Accepted

@jtsmedley jtsmedley linked a pull request Jan 30, 2023 that will close this issue
Macil added a commit to Macil/ipfs-deploy that referenced this issue Feb 4, 2023
Issue that lead to it being disabled has been fixed:
filebase/filebase-js#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants