Can't run `npm start` from VS Code terminal, but it works from `cmd`

70 Views Asked by At

My package.json:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "react": "^18",
    "react-dom": "^18",
    "next": "14.1.0"
  },
  "devDependencies": {
    "typescript": "^5",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "postcss": "^8",
    "tailwindcss": "^3.3.0",
    "eslint": "^8",
    "eslint-config-next": "14.1.0"
  }
}

It works when using cmd but I still get an error.

[![This is after I click the link to localhost in cmd][1]][1]

I want to see what my web page looks like from Live Server. I don't know how to see it when using Node/React.

*edit the output from npm start in command show error like this

npm ERR! Missing script: "start"
npm ERR! 
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in: C:\Users\USER\AppData\Local\npm-cache\_logs\2024-02-29T00_01_11_608Z-debug-0.log

after that i type npm run, but nothing happened. is there any error on script in package.json? [1]: https://i.stack.imgur.com/WeLxvl.png

1

There are 1 best solutions below

1
harry gordon On
  1. This could be a number of issues, I would suggest if you haven't already install and use NVM (Node version manager) to help manage your node version to make sure your node installation isn't the problem

  2. "npm start" is the wrong syntax since you are trying to run the scripts defined in your package.json; the correct syntax is "npm run start"

This issue could be elsewhere but without an error log its difficult to diagnose the correct issue