Home > Web Front-end > JS Tutorial > body text

npm run dev gives an error.

王林
Release: 2024-07-28 02:15:13
Original
638 people have browsed it

npm run dev gives an error.

We often encounter the error below when trying to start our react app.

packit-frontend@0.0.0 dev
vite

file:///home/ariel/Desktop/PackIt/PackIt-frontend/node_modules/vite/bin/vite.js:7
    await import('source-map-support').then((r) => r.default.install())
    ^^^^^

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
    at async link (internal/modules/esm/module_job.js:42:21)
Copy after login

This error is often caused by your node version being below the expected version. Below are some guides to help you fix that:

  1. check your node version.
node -v
Copy after login
  1. if your node version is lower than version 21, I will recommend you install node 21 or greater.
nvm install 21
Copy after login
  1. After the installation is done, you can now use the version 21.
nvm use 21
Copy after login
  1. Run the app again with
npm run dev
Copy after login

and the expected result should be:

> packit-frontend@0.0.0 dev
> vite


  VITE v5.3.4  ready in 222 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
Copy after login

The above is the detailed content of npm run dev gives an error.. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template