Skip to content

Failed to load from ES module #261

Open
@vsekhar

Description

@vsekhar

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions