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

Failed to load from ES module #261

Open
vsekhar opened this issue Apr 15, 2024 · 0 comments
Open

Failed to load from ES module #261

vsekhar opened this issue Apr 15, 2024 · 0 comments

Comments

@vsekhar
Copy link

vsekhar commented Apr 15, 2024

Describe the bug
SyntaxError: Unexpected token 'export' when importing to a module.

To Reproduce
Steps to reproduce the behavior:

  1. Create minimal scikit.js:
import * as tf from '@tensorflow/tfjs';
import * as sk from 'scikitjs';
sk.setBackend(tf)
  1. Run using node scikit.js.
  2. Error:
(node:576418) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/workspace/node_modules/scikitjs/dist/esm/index.js:15
export { LinearRegression } from './linear_model/LinearRegression';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:128:18)
    at wrapSafe (node:internal/modules/cjs/loader:1280:20)
    at Module._compile (node:internal/modules/cjs/loader:1332:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at cjsLoader (node:internal/modules/esm/translators:366:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:315:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)

Node.js v20.12.2

Desktop (please complete the following information):

  • OS: Ubuntu Jammy
  • Version: Scikitjs 1.24.0

Additional context
It may be related to unspecified ESM/CJS in package.json.

See recommendations here: https://publint.dev/[email protected]

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

1 participant