当我试图用npm start命令调试我的节点应用程序时,我收到了这个错误。

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/issues>npm 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:
Error: missing script: start
       at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:142:19)
       at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:58:5
       at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:345:5
       at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:309:45)
       at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:343:3)
       at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:113:5)
       at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:300:12
       at evalmachine.<anonymous>:334:14
       at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:102:5
       at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)

当前回答

关于脚本还有更多的答案。这是我的两分钱。如果你有同样的问题刚刚创建react应用程序或刚开始在一天的工作,在大多数情况下,这就是发生了什么。您可能无法进入创建的项目。

假设你创建了一个react应用my-app。然后,在运行NMP start命令之前,必须进入应用程序内部。

1. 我的程序光盘

2. npm开始

它会工作得很好。

其他回答

我在vscode中创建一个react项目后出现了这个错误。在vscode中关闭并重新打开vscode并以cmd模式创建一个新终端后,问题就解决了。

我只是偶然发现了这个问题。我重新安装了NPM,创建了一个新的React应用程序(所以基本上是一个干净的安装),仍然没有运气。 终于弄明白了:

我的终端机不在正确的位置。

我必须将directory更改到我的应用程序更深一层。 所以我的终端在“projects”文件夹里,而不是“my-app”文件夹里

路径:/文件/项目/ app的

如果您正在使用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

希望能帮到别人。 如果没有从项目的根目录打开项目,也会发生此错误。在VS code中打开之前,请确保cd到文件夹中。

请在package.json中的script object中使用下面这行代码

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

对我来说,它运行得非常好。