运行npm start时启动脚本丢失错误

使用npm start命令尝试debugging节点应用程序时收到此错误。

错误:

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! 节点v0.12.7 npm ERR! npm v2.11.3

npm ERR! 缺less脚本:启动npm ERR! npm ERR! 如果您需要帮助,您可以在以下url报告此错误:npm ERR! https://github.com/npm/npm/issues npm ERR! 请包括以下文件与任何支持请求:npm ERR! C:\ Users \用户andrmoll.NORTHAMERICA \文档\ GitHub的\ SVIChallenge \ NPM-的debug.log

从debugging文件:

详细堆栈错误:缺less脚本:开始

运行时的详细堆栈(C:\ Program Files \ nodejs \ node_modules \ npm \ lib \ run-script.js:142:19)

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

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

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

(C:\ Program Files \ nodejs \ node_modules \ npm \ node_modules \ read-package-json \ read-json.js:343:3)

(C:\ Program Files \ nodejs \ node_modules \ npm \ node_modules \ read-package-json \ read-json.js:113:5)

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

在evalmachine.:334:14有4个详细的堆栈

C:\ Program Files \ nodejs \ node_modules \ npm \ node_modules \ graceful-fs \ graceful-fs.js:102:5

FSReqWrap.oncomplete中的详细堆栈(evalmachine.:95:15)

看起来您可能没有在package.json文件中定义start脚本,或者您的项目不包含server.js文件。

如果你的包的根目录中有一个server.js文件,那么npm会默认start节点到server.js节点。

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

您可以将您的应用程序脚本的名称更改为server.js或将以下内容添加到您的package.json

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

或者…你可以直接运行node your-script.js

如果在package.json文件中添加了第二个“脚本”键,也会发生此错误。 如果您只是在package.json中留下一个“脚本”键,错误就会消失。

在我的情况下,它不工作,因为我使用“脚本”:两次。 结合后 – 没关系。

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

请在package.json中使用脚本对象中的以下代码行

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

对我来说,它工作得很好。

如果您正在使用babelify和watchify,请转到:

的package.json

并添加到“脚本”中:

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

一个例子是:

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

感谢DevSlopes的Mark Price

确保PORTS已打开

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

BLAL BLA BLA,最后你有这个

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

在节点js中仍然是一个新手,但是这导致了更多的这一点。

“scripts”:{“prestart”:“npm install”,“start”:“http-server -a localhost -p 8000 -c-1”}根据你自己的configuration,在你的package.json中添加这段代码。

我解决了我的问题。 它不是NPM错误它与代理行为有关。

如果你在代理后面,

 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" 

检查包含“scripts”属性的package.json文件是否存在。 如果不是这样更新脚本属性的话

 { "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" }