Next.js Discord

Discord Forum

ES Module error on new project

Unanswered
American Crocodile posted this in #help-forum
Open in Discord
American CrocodileOP
Hi there,
I'm getting the following error when starting the dev server on a new initialized project (no changes have been made).
Any idea where something is wrong?

(node:14812) 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)

1 Reply

I'm getting the same error. I have type: "module" in my package.json so I am unsure as to what it may be.

Brand new project (ignore the port error, I threw up another project real quick to get the output)

❯ npm run dev

> my-app@0.1.0 dev
> next dev

 ⚠ Port 3000 is in use, trying 3001 instead.
  ▲ Next.js 14.2.3
  - Local:        http://localhost:3001

 ✓ Starting...
 ✓ Ready in 1451ms
 ○ Compiling / ...
(node:366715) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:366715) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
 ✓ Compiled / in 3.4s (532 modules)
 GET / 200 in 3750ms
 ✓ Compiled in 344ms (250 modules)
 GET / 200 in 38ms
 ✓ Compiled /favicon.ico in 410ms (303 modules)
 GET /favicon.ico 200 in 469ms