Shahan
Shahan

Reputation: 23

Cannot use import statement outside a module for npm package

I am trying to use the npm package editly.

import Editly from "editly"

However when i try to import it i get this error.

SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47

All the solutions i have viewed say to add "type": "module" to package.json but it already has it

Upvotes: 1

Views: 3282

Answers (2)

Roberto Guerra
Roberto Guerra

Reputation: 1

Check your node version! you need upgrade to 16 or newer.

Upvotes: 0

Ranvir Choudhary
Ranvir Choudhary

Reputation: 49

Try updating node. Maybe your node version is outdated. uninstall node and reinstall again.

Upvotes: 0

Related Questions