当我试图用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项目,你可以尝试升级npm,然后升级react-cli

npm -g install npm@version
npm install -g create-react-app

其他回答

npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app

重要:确保你需要更改目录到my-app,然后点击“npm start”

正如您在图像中所看到的,有一个错误,在更改目录后修复了这个错误。

另一个可能的原因是:当你的项目在yarn中初始化时,你正在使用npm。(这是我自己做的)。所以它将是yarn start而不是npm start。

现在不鼓励全局安装create-react-app。相反,通过执行以下命令卸载全局安装的create-react-app包:npm uninstall -g create-react-app(如果这个命令对你不起作用,你可能不得不手动删除包文件夹。一些用户报告说,他们不得不手动删除文件夹)

然后你可以运行npx create-react-app my-app来再次创建react app。

裁判:https://github.com/facebook/create-react-app/issues/8086

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

检查包装。Json文件,并在此文件中找到您的脚本名称