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

Cannot use import statement outside a module #118

Closed
GuillaumeDesforges opened this issue Sep 11, 2022 · 2 comments
Closed

Cannot use import statement outside a module #118

GuillaumeDesforges opened this issue Sep 11, 2022 · 2 comments
Labels

Comments

@GuillaumeDesforges
Copy link

Describe the bug
I'm trying to use remult in my project. I'd like to use ES modules.

I get the following error:

(node:2822177) 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)
/home/me/ts-app-esm-template/node_modules/remult/esm/remult-express.js:1
import * as express from 'express';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)

Node.js v18.3.0

See GuillaumeDesforges/ts-app-esm-template#1

To Reproduce
Steps to reproduce the behavior:

WARNING requires node >= 18.x

  1. clone https://github.com/GuillaumeDesforges/ts-app-esm-template
  2. yarn install
  3. yarn build
  4. node api

Expected behavior
The import should not fail.

@noam-honig
Copy link
Collaborator

Please let us know that it works for you

@GuillaumeDesforges
Copy link
Author

Worked great, thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants