parallel.js icon indicating copy to clipboard operation
parallel.js copied to clipboard

Import parallel with ESM (experimental node) fails

Open fserb opened this issue 4 years ago • 1 comments

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.

fserb avatar Apr 10 '20 18:04 fserb

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.

benbucksch avatar May 14 '20 00:05 benbucksch