繁体   English   中英

Node.js中的NPM错误

[英]NPM error in Node.js

我正在尝试成功部署在Heroku上部署的Todo路由,但显示应用程序错误。 当检查heroku日志文件时,它显示日志文件中提到的以下错误

我已经使用了node.js mongodb mongooseHerokumlab进行部署

节点版本

节点版本节点:8.11.2

日志文件

2018-06-23T10:53:43.168794+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-06-23T10:53:43.169086+00:00 app[web.1]: npm ERR!
2018-06-23T10:53:43.169299+00:00 app[web.1]: npm ERR! Failed at the nodetodo@1.0.0 prestart script.
2018-06-23T10:53:43.169500+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-06-23T10:53:43.174385+00:00 app[web.1]:
2018-06-23T10:53:43.174622+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-06-23T10:53:43.174799+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-06-23T10_53_43_171Z-debug.log
2018-06-23T10:53:43.275561+00:00 heroku[web.1]: State changed from crashed to starting
2018-06-23T10:53:46.634454+00:00 heroku[web.1]: Starting process with command `npm start`
2018-06-23T10:53:49.572029+00:00 heroku[web.1]: Process exited with status 1
2018-06-23T10:53:49.589326+00:00 heroku[web.1]: State changed from starting to crashed
2018-06-23T10:53:49.452654+00:00 app[web.1]:
2018-06-23T10:53:49.452675+00:00 app[web.1]: > nodetodo@1.0.0 prestart /app
2018-06-23T10:53:49.452677+00:00 app[web.1]: > next build
2018-06-23T10:53:49.452678+00:00 app[web.1]:
2018-06-23T10:53:49.461849+00:00 app[web.1]: sh: 1: next: not found
2018-06-23T10:53:49.476477+00:00 app[web.1]: npm ERR! file sh
2018-06-23T10:53:49.476762+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-06-23T10:53:49.477051+00:00 app[web.1]: npm ERR! errno ENOENT
2018-06-23T10:53:49.477332+00:00 app[web.1]: npm ERR! syscall spawn
2018-06-23T10:53:49.479006+00:00 app[web.1]: npm ERR! nodetodo@1.0.0 prestart: `next build`
2018-06-23T10:53:49.479274+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-06-23T10:53:49.479567+00:00 app[web.1]: npm ERR!
2018-06-23T10:53:49.479782+00:00 app[web.1]: npm ERR! Failed at the nodetodo@1.0.0 prestart script.
2018-06-23T10:53:49.479988+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-06-23T10:53:49.488380+00:00 app[web.1]:
2018-06-23T10:53:49.488650+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-06-23T10:53:49.488830+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-06-23T10_53_49_481Z-debug.log
2018-06-23T10:53:57.235315+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/todos" host=glacial-mesa-32050.herokuapp.com request_id=0cbc6b93-45b5-4e60-a716-6e87f9cfe8b5 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:53:57.875585+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=8a8c1304-b9ca-4684-8306-a70dca54e911 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:54:00.250909+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/todos" host=glacial-mesa-32050.herokuapp.com request_id=d4de12e1-d453-4a62-9ee0-4a99e2f78051 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:54:00.896607+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=8e52a8d5-2bd2-4e95-a8e6-7e43c21bd369 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:54:04.255637+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/todos" host=glacial-mesa-32050.herokuapp.com request_id=8d68216f-f176-4f79-91b5-cb10b02c8fc3 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:54:04.866164+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=5ebf6203-d866-42ff-baf7-f57179248c73 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:54:06.844189+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/todos" host=glacial-mesa-32050.herokuapp.com request_id=11ce1294-b8a5-4046-ad2b-1db482422355 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:54:07.474661+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=98c0098c-c969-4491-99d3-aa6f29eb836f fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:57:10.708198+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=glacial-mesa-32050.herokuapp.com request_id=b3fc81b7-4a7a-438c-8482-e0b68b8e52d0 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:57:11.197790+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=b8c7fff9-7304-4e63-8fea-50d9e7525cf2 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:57:21.844958+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/todos" host=glacial-mesa-32050.herokuapp.com request_id=b0fa0c40-3fed-4da9-b680-6b55864ae418 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T10:57:24.013893+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=8b0ac5ed-ea76-4ee4-b1a8-99ba8520c986 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T11:05:45.000000+00:00 app[api]: Build started by user @gmail.com
2018-06-23T11:05:58.286485+00:00 app[api]: Deploy 6ab35c64 by user @gmail.com
2018-06-23T11:05:58.286485+00:00 app[api]: Release v5 created by user @gmail.com
2018-06-23T11:05:58.000000+00:00 app[api]: Build succeeded
2018-06-23T11:06:00.741880+00:00 heroku[web.1]: State changed from crashed to starting
2018-06-23T11:06:04.111616+00:00 heroku[web.1]: Starting process with command `npm start`
2018-06-23T11:06:06.707945+00:00 app[web.1]:
2018-06-23T11:06:06.707971+00:00 app[web.1]: > nodetodo@1.0.0 start /app
2018-06-23T11:06:06.707972+00:00 app[web.1]: > node server/server.js
2018-06-23T11:06:06.707974+00:00 app[web.1]:
2018-06-23T11:06:07.594283+00:00 app[web.1]: Started at port 38896
2018-06-23T11:06:07.622294+00:00 app[web.1]:
2018-06-23T11:06:07.622298+00:00 app[web.1]: /app/node_modules/mongoose/node_modules/mongodb/lib/server.js:242
2018-06-23T11:06:07.622300+00:00 app[web.1]: process.nextTick(function() { throw err; })
2018-06-23T11:06:07.622302+00:00 app[web.1]: ^
2018-06-23T11:06:07.622338+00:00 app[web.1]: Error: connect ECONNREFUSED 127.0.0.1:27017
2018-06-23T11:06:07.622340+00:00 app[web.1]: at Object._errnoException (util.js:992:11)
2018-06-23T11:06:07.622342+00:00 app[web.1]: at _exceptionWithHostPort (util.js:1014:20)
2018-06-23T11:06:07.622344+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
2018-06-23T11:06:07.632652+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-06-23T11:06:07.633131+00:00 app[web.1]: npm ERR! errno 1
2018-06-23T11:06:07.634834+00:00 app[web.1]: npm ERR! nodetodo@1.0.0 start: `node server/server.js`
2018-06-23T11:06:07.635359+00:00 app[web.1]: npm ERR!
2018-06-23T11:06:07.635590+00:00 app[web.1]: npm ERR! Failed at the nodetodo@1.0.0 start script.
2018-06-23T11:06:07.635057+00:00 app[web.1]: npm ERR! Exit status 1
2018-06-23T11:06:07.635807+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-06-23T11:06:07.642357+00:00 app[web.1]:
2018-06-23T11:06:07.642642+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-06-23T11:06:07.642830+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-06-23T11_06_07_637Z-debug.log
2018-06-23T11:06:07.695625+00:00 heroku[web.1]: Process exited with status 1
2018-06-23T11:06:07.822414+00:00 heroku[web.1]: State changed from starting to crashed
2018-06-23T11:06:07.826000+00:00 heroku[web.1]: State changed from crashed to starting
2018-06-23T11:06:10.546996+00:00 heroku[web.1]: Starting process with command `npm start`
2018-06-23T11:06:12.650782+00:00 app[web.1]:
2018-06-23T11:06:12.650804+00:00 app[web.1]: > nodetodo@1.0.0 start /app
2018-06-23T11:06:12.650806+00:00 app[web.1]: > node server/server.js
2018-06-23T11:06:12.650807+00:00 app[web.1]:
2018-06-23T11:06:13.248399+00:00 app[web.1]: Started at port 4126
2018-06-23T11:06:13.264689+00:00 app[web.1]:
2018-06-23T11:06:13.264697+00:00 app[web.1]: process.nextTick(function() { throw err; })
2018-06-23T11:06:13.264695+00:00 app[web.1]: /app/node_modules/mongoose/node_modules/mongodb/lib/server.js:242
2018-06-23T11:06:13.264699+00:00 app[web.1]: ^
2018-06-23T11:06:13.264700+00:00 app[web.1]: Error: connect ECONNREFUSED 127.0.0.1:27017
2018-06-23T11:06:13.264701+00:00 app[web.1]: at Object._errnoException (util.js:992:11)
2018-06-23T11:06:13.264703+00:00 app[web.1]: at _exceptionWithHostPort (util.js:1014:20)
2018-06-23T11:06:13.264705+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
2018-06-23T11:06:13.271195+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-06-23T11:06:13.271503+00:00 app[web.1]: npm ERR! errno 1
2018-06-23T11:06:13.272534+00:00 app[web.1]: npm ERR! nodetodo@1.0.0 start: `node server/server.js`
2018-06-23T11:06:13.272816+00:00 app[web.1]: npm ERR!
2018-06-23T11:06:13.272926+00:00 app[web.1]: npm ERR! Failed at the nodetodo@1.0.0 start script.
2018-06-23T11:06:13.272642+00:00 app[web.1]: npm ERR! Exit status 1
2018-06-23T11:06:13.273028+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-06-23T11:06:13.276839+00:00 app[web.1]:
2018-06-23T11:06:13.276972+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-06-23T11:06:13.277055+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-06-23T11_06_13_274Z-debug.log
2018-06-23T11:06:13.324927+00:00 heroku[web.1]: Process exited with status 1
2018-06-23T11:06:13.471063+00:00 heroku[web.1]: State changed from starting to crashed
2018-06-23T11:06:20.993262+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=glacial-mesa-32050.herokuapp.com request_id=6458108b-77d2-485c-ba53-9e523f8fff7f fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https
2018-06-23T11:06:21.472089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-mesa-32050.herokuapp.com request_id=dc99750e-aaba-4fc9-b7f5-fde727eb6201 fwd="111.91.116.52" dyno= connect= service= status=503 bytes= protocol=https

JSON文件

{
  "name": "nodetodo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node server/server.js",
    "test": "mocha server/**/*.test.js",
    "test-watch": "nodemon --exec \"npm test\""
  },
  "engines": {
    "node": "8.11.2"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.3",
    "express": "^4.16.3",
    "mongodb": "^2.2.35",
    "mongoose": "^4.5.9"
  },
  "devDependencies": {
    "expect": "^1.20.2",
    "mocha": "^3.0.2",
    "nodemon": "^1.10.2",
    "supertest": "^2.0.0"
  }
}

请帮忙

您是否尝试过npm cache clean -f?

好的,此错误可能是由于两个原因引起的,因此请确保您正确执行了这些步骤

确保绑定您的端口

const PORT = process.env.PORT || 4126;
   app.listen(PORT);

确保您连接到联机数据库,而不是本地数据库。请使用mlab uri。 https://mlab.com/使用此链接获得帮助学习Mlab

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM