Skip to content

Cannot use import statement outside a module Error on node 18 #81

Description

@masterfabela

When I try to import this package in Node, I encounter an error that seems to originate from an internal import within the package.

(node:18) 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/projects/node-99aw1w/node_modules/meteojs/index.js:40
import 'regenerator-runtime/runtime.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (https://node99aw1w-3gkv.w-credentialless-staticblitz.com/builtins.5bf3667c.js:266:849)
    at wrapSafe (https://node99aw1w-3gkv.w-credentialless-staticblitz.com/builtins.5bf3667c.js:144:13497)
    at Module._compile (https://node99aw1w-3gkv.w-credentialless-staticblitz.com/builtins.5bf3667c.js:144:13881)
    at Module._extensions..js (https://node99aw1w-3gkv.w-credentialless-staticblitz.com/builtins.5bf3667c.js:144:14855)
    at Module.load (https://node99aw1w-3gkv.w-credentialless-staticblitz.com/builtins.5bf3667c.js:144:12820)
    at Module._load (https://node99aw1w-3gkv.w-credentialless-staticblitz.com/builtins.5bf3667c.js:144:10273)

Node.js 18.20.3

I have created a demo where this issue can be reproduced:

https://stackblitz.com/edit/node-lvdcei?file=index.js

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions