N
Nuxt8mo ago
Type-32

npm run dev ES module error

/opt/homebrew/bin/npm run dev

> dev
> nuxt dev

(node:53004) 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)
/Users/administrator/Documents/WebStorm Projects/doism/node_modules/.bin/nuxt:3
import { fileURLToPath } from 'node:url'
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1290:20)
at Module._compile (node:internal/modules/cjs/loader:1342:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49

Node.js v21.6.0

Process finished with exit code 1
/opt/homebrew/bin/npm run dev

> dev
> nuxt dev

(node:53004) 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)
/Users/administrator/Documents/WebStorm Projects/doism/node_modules/.bin/nuxt:3
import { fileURLToPath } from 'node:url'
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1290:20)
at Module._compile (node:internal/modules/cjs/loader:1342:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49

Node.js v21.6.0

Process finished with exit code 1
The above is the logs when I try to run the new created nuxt app (using npx and npm as configured package manager) with npm run dev.
1 Reply
Type-32
Type-32OP8mo ago
node version is 21.6.0 npm version is 10.2.4 okay I deleted the node_modules folder and deleted the package-lock.json file and ran npm install again and it worked fine again idk why
Want results from more Discord servers?
Add your server