22
users-iMac-2:backend NEHAL$ npm run dev

> dev
> vite

file:///Users/user/Desktop/backend/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:122:18)
    at async link (internal/modules/esm/module_job.js:42:21)
users-iMac-2:backend NEHAL$ 
Nipun Tharuksha
  • 2,496
  • 4
  • 17
  • 40
Nehal Ahmed Khan
  • 221
  • 1
  • 2
  • 4
  • did run `npm i` after initiating the project ? – medilies Jul 20 '22 at 18:05
  • According to [laravel 9 docs](https://laravel.com/docs/9.x/vite#installing-node) for working vite in laravel You must ensure that Node.js (16+) and NPM are installed. For developers that are using windows 7 I suggest to read [this question](https://stackoverflow.com/questions/62212754/latest-nodejs-compatible-with-windows-7) – hamid-davodi Aug 02 '22 at 14:41

5 Answers5

16

Same problem. Updated node to v16.16.0 and it worked.

gs101
  • 161
  • 6
10

I had the same problem; the installed version of NodeJS on your OS is incompatible with vite; mine was v12.22.9; upgrade yours.

If you're using a debian-based OS, run the following.

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
X 47 48 - IR
  • 1,250
  • 1
  • 15
  • 28
  • @X 47 48 - IR did you test with node v12.22.9 and it works? I have node ```v13.14.0``` in my windows 7 and get the same error. Do you have any solution for me? Because as I know newer versions of **Node** do not work with windows 7. – hamid-davodi Jul 31 '22 at 04:19
  • Try using `Docker` (It's independent of the OS); I have dockerized everything myself. It's so easy to catch up with new updates. – X 47 48 - IR Aug 01 '22 at 12:18
  • Thanks this worked for me, I was using docker. – MT_Shikomba Nov 03 '22 at 05:19
  • 1
    I use node version manager (https://github.com/nvm-sh/nvm), much easier to switch back and forth to the version you need. – user281681 Nov 16 '22 at 00:28
  • Great method! Seems like a newer version has been released. I think people try this method should also check the latest version. (Do Ctrl+F "setup_" in the following official page to know the latest version) https://github.com/nodesource/distributions – Exis Feb 22 '23 at 23:45
2

Because you are using lower Nodejs version, you can install multi Nodejs version and change between them In my case I install

v14.0.0
v16.0.0
v18.0.0

In your case you should use version v16.0.0 OR v18.0.0 run terminal as admin and run this command to use a specific version:

nvm use v18.0.0

And rerun command again

npm run dev

It works without any problem

Eng_Farghly
  • 1,987
  • 1
  • 23
  • 34
1

Primarily, you try installing Node.js like v16/v18. you got rid of the error message on Ubuntu.

Err:10 https://ppa.launchpadcontent.net/certbot/certbot/ubuntu jammy Release
  404  Not Found [IP: 2620:2d:4000:1::3e 443]
Reading package lists... Done
W: https://repos.insights.digitalocean.com/apt/do-agent/dists/main/InRelease: Key is , see the DEPRECATION section in apt-key(8) for details.
E: The repository 'https://ppa.launchpadcontent.net/certbot/certbot/ubuntu jammy Rele
N: Updating from such a repository can't be done securely, and is therefore disabled 
N: See apt-secure(8) manpage for repository creation and user configuration details.
Error executing command, exiting

Used these commands to solve the ERROR :

sudo apt-add-repository -r ppa:certbot/certbot

After that, the following commands do not generate any errors:

sudo apt update
sudo apt-get update

Then install Nodejs from the Official github repo

and make Vuejs build from npx vite build for Npm build from npm run build.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
1

Use yarn instead First remove package-lock.json and node_modules folder.

rm -rf node_modules/ package-lock.json

Then run:

yarn install 

Run build command:

yarn build # or yran dev