0

I want to build a vue project.I use npm init vue@latest to init my project.Then I run npm install to install packages.But When I run npm run dev.I met an error. enter image description here

Then I run npm run vite preview --port 4173.But It shows that I don't have a vite Script.Then I run npm install vite.It does not work.Please help me.Thanks a lot. enter image description here

this is my package.json

{
  "name": "weathercheck",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview --port 4173"
  },
  "dependencies": {
    "vue": "^3.2.38",
    "vue-router": "^4.1.5"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^3.0.3",
    "vite": "^3.1.3"
  }
}

1 Answer 1

3

The first error indicates that you are using an older version of node.js. I recently bumped into that. Check this thread for more details

As per vite's site:

Compatibility Note

Vite requires Node.js version 14.18+, 16+. However, some templates require a higher Node.js version to work, please upgrade if your package manager warns about it.

The second error is quite correct though. There is no such script called vite in your package.json.

try npm run preview.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.