Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting vite:command not found error?

Tags:

vite

I have installed vite in my vue.js app. I start the app by typing npm run dev in the main project directory. In the package.json this is defined as:

"dev": "vite"

but if I try do run this command (or eg. vite build) 'manually' from main directory, I get an error:

bash: vite: command not found

I also figured out that when I set a new script:

"build": "vite build"

I can run this command also, although, again, running it manually will result in error as above.

This seems quite illogical to me. Can anybody explain how is it possible?

like image 953
DuchSuvaa Avatar asked Aug 26 '26 21:08

DuchSuvaa


1 Answers

If you didn't install vite globally (using npm install -g), then the vite command will be in node_modules/.bin in your main directory. The npm run command temporarily adds that folder to your PATH so it can execute that command. Try running ./node_modules/.bin/vite to run it without npm.

like image 196
Yitz Avatar answered Aug 28 '26 09:08

Yitz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!