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

当前回答

确保端口是打开的

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

诸如此类,最后你得到了这个

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

在node js中仍然是一个新手,但这导致了更多的这种情况。

其他回答

看起来您可能没有在包中定义开始脚本。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

检查包装。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"
}

我在第一次安装react-js时遇到了这个问题: 这几句话帮助我解决了问题:

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

来源:https://stackoverflow.com/a/59260128/11652661

试试这个方法,它会对你有用的

根据react文档https://create-react-app.dev/docs/getting-started/ 下面的命令将解决这个问题。

npx create-react-app my-app
cd my-app
npm start