parallel.js
parallel.js copied to clipboard
Import parallel with ESM (experimental node) fails
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.
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:
-
jq "." node_modules/paralleljs/package.json > foo
- `mv foo node_modules/paralleljs/package.json
-
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.