I am struggling to run my react js project using npm run dev, which was created using vite. Whenever I run it using npm run dev it says, npm ERR! Missing script: "dev" and I have installed npm and vite already.
I have vite and dev in my package.json file
2
Answers
Please copy your package.json file, so that anyone can understand and answer the question better way.
Your package.json file must include this code.
When you install Vite (with
npm create vite@latest
, found on Vite’s set up guide) and Node.js/NPM, a package.json file is created which, when done using Vite, should automatically set up the dev, build and preview scripts inside package.json. An example of a package.json file created with Vite is below:You won’t be able to start your Vite project using
npm run dev
unless you’ve either added the dev script yourself or created your Vite project usingnpm create vite@latest
. Just having NPM and Vite installed isn’t enough if you don’t have a working package.json file.Showing the content of your package.json file however would be helpful to check if these scripts are inside. You can edit your question to include this.