当我试图用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)

当前回答

我也有同样的问题。我试着在包中写一个代码。Json文件如下

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

其他回答

如果在包中添加第二个“scripts”键,也会发生此错误。json文件。如果您只在包中留下一个“脚本”键。Json时,错误消失。

看起来您可能没有在包中定义开始脚本。Json文件或您的项目不包含server.js文件。

如果在你的包的根目录中有一个server.js文件,那么npm将默认启动命令到node server.js。

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

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

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

还是……你可以直接运行node your-script.js

我已经解决了我的问题。这不是一个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"

你可能有一个旧的(全局的)npm安装导致了这个问题。截至12月19日,npm不支持全局安装。

首先,使用以下方法卸载包: NPM卸载-g create-react-app

一些osx/Linux用户可能还需要使用以下方法删除旧的npm: Rm -rf /usr/local/bin/create-react-app

这是目前唯一支持的生成项目的方法: create-react-app my-app

最后你可以运行: npm开始

当我尝试运行"npm run start"时,我得到了同样的错误

我的项目应该以npm run serve启动

如果你复制一个github项目,你可以看看项目设置,就像这样:

所以一定要确保你用正确的命令运行它,在我的例子中是

npm run serve