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

Import parallel with ESM (experimental node) fails #186

Open
fserb opened this issue Apr 10, 2020 · 1 comment
Open

Import parallel with ESM (experimental node) fails #186

fserb opened this issue Apr 10, 2020 · 1 comment

Comments

@fserb
Copy link

fserb commented Apr 10, 2020

Importing parallel with: import Parallel from "paralleljs", the following error happens:

internal/modules/esm/resolve.js:61
  let url = moduleWrapResolve(specifier, parentURL);
            ^

Error: Invalid JSON in node_modules/paralleljs/package.json imported from script.js
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:61:13)
    at Loader.resolve (internal/modules/esm/loader.js:85:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:191:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:42:40)
    at link (internal/modules/esm/module_job.js:41:36) {
  code: 'ERR_INVALID_PACKAGE_CONFIG'
}

If I remove paralleljs/package.json and import with "paralleljs/lib/parallel.js"`, then it works fine.

@benbucksch
Copy link
Contributor

benbucksch commented May 14, 2020

I see this bug when I install the npm module using yarn add paralleljs. Note that the package there is 6 years old.

When I import this repo using yarn add https://github.com/parallel-js/parallel.js/, I get a different error, see #187.

One workaround, if you want to use the old npm package, is to fix up the JSON syntax:

  1. jq "." node_modules/paralleljs/package.json > foo
  2. `mv foo node_modules/paralleljs/package.json
  3. rm foo
    but you won't get the features added in the last 6 years.

The proper fix for this bug is to update npm to the latest version in github. #187 also needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants