dankogai / js-combinatorics

power set, combination, permutation and more in JavaScript
MIT License
742 stars 97 forks source link

Doesn't work on esm? #86

Closed shirshak55 closed 1 year ago

shirshak55 commented 3 years ago

I get so many weird errors import $C from "js-combinatorics"

export const version = '1.5.4';
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1025:15)
    at Module._compile (node:internal/modules/cjs/loader:1059:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:281:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If I use this: import { Combination, Permutation } from "js-combinatorics";

It gives:


import { Combination, Permutation } from "js-combinatorics";
         ^^^^^^^^^^^
SyntaxError: Named export 'Combination' not found. The requested module 'js-combinatorics' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
shahata commented 1 year ago

This is fixed since version 1.5.5, suggest to close the issue