Start script missing error when running npm start

一曲冷凌霜 提交于 2019-11-26 12:35:35

问题


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

Error:

npm ERR! Windows_NT 6.3.9600 npm ERR! argv \"C:\\Program Files\\nodejs\\\\node.exe\" \"C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\" \"start\" npm ERR! node v0.12.7 npm ERR! npm v2.11.3

npm ERR! missing script: start npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issuesnpm ERR! Please include the following file with any support request: npm ERR! C:\\Users\\andrmoll.NORTHAMERICA\\Documents\\GitHub\\SVIChallenge\\npm-debug.log

From the debug file:

verbose stack Error: missing script: start

4 verbose stack at run (C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\run-script.js:142:19)

4 verbose stack at C:\\Program Files\\nodejs\\node_modules\\npm\\lib\\run-script.js:58:5

4 verbose stack at C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\read-package-json\\read-json.js:345:5

4 verbose stack at checkBinReferences_ (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\read-package-json\\read-json.js:309:45)

4 verbose stack at final (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\read-package-json\\read-json.js:343:3)

4 verbose stack at then (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\read-package-json\\read-json.js:113:5)

4 verbose stack at C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\read-package-json\\read-json.js:300:12

4 verbose stack at evalmachine.:334:14

4 verbose stack at C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\graceful-fs\\graceful-fs.js:102:5

4 verbose stack at FSReqWrap.oncomplete (evalmachine.:95:15)


回答1:


It looks like you might not have defined a start script in your package.json file or your project does not contain a server.js file.

If there is a server.js file in the root of your package, then npm will default the start command to node server.js.

https://docs.npmjs.com/misc/scripts#default-values

You could either change the name of your application script to server.js or add the following to your package.json

"scripts": {
    "start": "node your-script.js"
}

Or ... you could just run node your-script.js directly




回答2:


This error also happens if you added a second "script" key in the package.json file. If you just leave one "script" key in the package.json the error disappears.




回答3:


In my case, it wasn't working because I used "scripts" twice. After combining - it is ok.

"scripts": {
  "test": "make test",
  "start": "node index.js"
}



回答4:


Please use the below line of code in script object which is there in package.json

"scripts": {
    "start": "webpack-dev-server --hot"
}

For me it worked perfectly fine.




回答5:


If you are using babelify and watchify, go to:

package.json

and add this in "scripts":

"scripts": {
    "start": "watchify the-path-to-your-source-jsx-file -v -t [ babelify --presets [ react ] ] -o the-path-to-your-output-js-file"
}

An example would be:

"scripts": {
    "start": "watchify src/main.jsx -v -t [ babelify --presets [ react ] ] -o public/js/main.js"
}

Thanks to Mark Price from DevSlopes




回答6:


Make sure the PORTS ARE ON

var app = express();
app.set('port', (process.env.PORT || 5000));

BLAL BLA BLA AND AT THE END YOU HAVE THIS

app.listen(app.get('port'), function() {
    console.log("Node app is running at localhost:" + app.get('port'))
});

Still a newbee in node js but this caused more of this.




回答7:


check package.json file having "scripts" property is there or not. if not update script property like this

{
  "name": "csvjson",
  "version": "1.0.0",
  "description": "upload csv to json and insert it into MongoDB for a single colletion",
  "scripts": {
    "start": "node csvjson.js"
  },
  "dependencies": {
    "csvjson": "^4.3.4",
    "fs": "^0.0.1-security",
    "mongodb": "^2.2.31"
  },
  "devDependencies": {},
  "repository": {
    "type": "git",
    "url": "git+https://github.com/giturl.git"
  },
  "keywords": [
    "csv",
    "json",
    "mongodb",
    "nodejs",
    "collection",
    "import",
    "export"
  ],
  "author": "karthikeyan.a",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/homepage/issues"
  },
  "homepage": "https://github.com/homepage#readme"
}



回答8:


should avoid using unstable npm version.

I observed one thing that is npm version based issue, npm version 4.6.1 is the stable one but 5.x is unstable because package.json will be configured perfectly while creating with default template if it's a stable version and so we manually don't need to add that scripts.

I got the below issue on the npm 5 so I downgraded to npm 4.6.1 then its worked for me,


ERROR: npm 5 is not supported yet


It looks like you're using npm 5 which was recently released.

Create React Native App doesn't work with npm 5 yet, unfortunately. We recommend using npm 4 or yarn until some bugs are resolved.

You can follow the known issues with npm 5 at: https://github.com/npm/npm/issues/16991


Devas-MacBook-Air:SampleTestApp deva$ npm start npm ERR! missing script: start




回答9:


If you are running two application same time , close one and then build and run application




回答10:


"scripts": {
  "prestart": "npm install",
  "start": "http-server -a localhost -p 8000 -c-1"
}

add this code snippet in your package.json, depending on your own configuration.




回答11:


Another possible reason: you're using npm when your project is initialized in yarn. (I did this myself). So it would be yarn start instead of npm start.




回答12:


I have the same issue. I try to write a code in package.json file as below

    "scripts": {
    "start": "<your-script-file>.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },



回答13:


In my case following code working fine..

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "parcel index.html",
"build": "parcel build --public-url . index.html"  }



回答14:


I have solved mine. Its not an NPM Error its related to proxy behavior.

If you are behind proxy,

MAC
 1.  Goto System Preference (gears icon on your mac)
 2.  click your network
 3.  click advanced
 4.  click proxy
 5.  check excludes simple hostnames
 6.  add this line below (Bypass Proxy Settings...) "localhost, localhost:8080"

refer to the npm echo: "Project is running at http://localhost:8080/"

Windows
 1.  Goto your browser Proxy Settings (google it)
 2.  check Bypass local address
 3.  add this line below "localhost, localhost:8080"


来源:https://stackoverflow.com/questions/31976722/start-script-missing-error-when-running-npm-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!