npm start - npm ERR! missing script: start

2019-05-18 16:59发布

I'm receiving this error when trying to my node application using the npm start command.

WhenIi try to npm start I get this error.

Error:

 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 npm@5.6.0
    3 info using node@v8.10.0
    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)
    4 verbose stack     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:400:3)
    4 verbose stack     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
    4 verbose stack     at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
    4 verbose stack     at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
    4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
    5 verbose cwd B:\tut\starter
    6 verbose Windows_NT 6.1.7601
    7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
    8 verbose node v8.10.0
    9 verbose npm  v5.6.0
    10 error missing script: start
    11 verbose exit [ 1, true ]

From the debug file:

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

标签: node.js npm
2条回答
放荡不羁爱自由
2楼-- · 2019-05-18 17:45

Because there is no start script... Just change compile script to start script... Then it will compile your sass files...

"scripts": {
  "start": "node-sass sass/main.scss  css/style.css -w"
},
查看更多
beautiful°
3楼-- · 2019-05-18 17:48

You are missing the entry start in the scripts section of your package.json. If you want to compile the file using npm start then, you should copy node-sass sass/main.scss css/style.css -w and paste it as a value for start. You can add any command you would like to execute as the value for start.

Having said that, if you do npm "compile:sass" it will compile your sass files if you don't want to change your package.json.

"scripts": {
    ...
    "compile:sass": "node-sass sass/main.scss  css/style.css -w",
     "start": "node-sass sass/main.scss  css/style.css -w"
  },
查看更多
登录 后发表回答