skip to Main Content

I have a freshly installed Ubuntu 22.04.1 LTS on which I have installed npm and docker.

When I want to start my NextJS web server (npm run dev) and the following error message appears:


niklas@srv-code01:~/Desktop/Code/Javascript/NextJS/website_01$ npm run dev

> [email protected] dev
> next dev

/home/niklas/Desktop/Code/Javascript/NextJS/website_01/node_modules/next/dist/cli/next-dev.js:315
            showAll: args["--show-all"] ?? false,
                                         ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.dev (/home/niklas/Desktop/Code/Javascript/NextJS/website_01/node_modules/next/dist/lib/commands.js:10:30)
    at Object.<anonymous> (/home/niklas/Desktop/Code/Javascript/NextJS/website_01/node_modules/next/dist/bin/next:141:28)
    at Module._compile (internal/modules/cjs/loader.js:999:30)

I can’t see anything from the error message. What is the reason for the error? The error message also occurs with the following command: npm run start

I have the latest version of NPM installed.

Start of the NPM Development or Production Server on Port 3000

2

Answers


  1. You can try init project by npx create-next-app@latest, not npx create-next-app. It works for me. Good luck~

    Login or Signup to reply.
  2. I had the same error and to resolve that I used the node version manager(nvm) to update my node.js version to 18.12.1.

    To fix this, you need to follow the steps in this order-

    1. Run this command to get the nvm.
      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

    2. Restart your terminal.

    3. Install nvm- nvm install v18.12.1

    4. Start nvm- npm run dev

    You can use nvm list-remote to look at a complete list of the versions to choose from.

    For more information, read here under option 3-
    installing-node-using-the-node-version-manager

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search