Sid Halfyie
Sid Halfyie

Reputation: 11

Syntax error in node modules file on installation of vite

I created a new vite project with: npm install vite@latest

then chose my project name, selected React and Javascript + SWC then npm install but got this error when running: npm run dev

npm does not support Node.js v15.5.1
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/

> [email protected] dev
> vite

.../frontend_vite/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:38336
const inlineImportRE = /(?<!(?<!\.\.)\.)\bimport\s*\(("(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*')\)/dg;
                       ^

SyntaxError: Invalid regular expression flags

Any idea why this is happening?

Tried installing vite and running my project locally but immediately got this error. I have another vite project i created a few months ago, and i didn't encounter this issue.

Upvotes: 1

Views: 2697

Answers (1)

Jorge Garnica
Jorge Garnica

Reputation: 1276

The problem is that the version of nodeJS is not supported for your setup from Vite, there are maybe some libraries within Vite core that need a major version of NodeJS.

If you have other projects that need NodeJS 15.x.x you can start using NVM to run multiple versions of NodeJS on your machine. If not, you can just upgrade your NodeJS version or reinstall it with the latest version.

Upvotes: 2

Related Questions