Nodejs express throw npm err! missing script: start

Dung Do Tien Nov 26 2021 434

I have created a small project with Nodejs,

In my project, I have created App.js file and its main file to start the server.

When I run npm start command and I got an exception Error: missing script: start. Like this

0 info it worked if it ends with ok
    1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'start' ]
    2 info using [email protected]
    3 info using [email protected]
    4 verbose stack Error: missing script: start
    4 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:151:19)
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:61:5
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
    4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:402:5
    4 verbose stack     at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:357:45)

my package.json file

{
  "name": "sridhar",
  "version": "1.0.0",
  "description": "landing page",
  "main": "App.js",
  "scripts": {
    "compile:sass": "node-sass sass/main.scss  css/style.css -w"
  },
  "author": "sridhar",
  "license": "ISC",
  "devDependencies": {
    "node-sass": "^4.8.3"
  }
}

My environment: 

Window 10, node v12.18.3, npm v 6.14.6.

Thank you for any suggestions.

Have 2 answer(s) found.
  • Q

    Quang Nguyen Nov 26 2021

    You can change the config script in package.json file:

    From:

    "scripts": {
        "compile:sass": "node-sass sass/main.scss  css/style.css -w"
     }

    to

    "scripts": {
        "compile:sass": "node-sass sass/main.scss  css/style.css -w",
        "start": "node App.js"
     }

    After then build code and run npm start again.

  • P

    Praveen Kumar S Nov 26 2021

    You can try to run node App.js directly, no need to use npm start

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close