在Heroku中使用命令`npm start`启动进程

时间:2017-05-05 04:14:19

标签: node.js heroku vue.js

当我将应用程序部署到heroku时,我发现以下错误消息。 Heroku给了我以下错误消息

2017-05-05T04:01:57.462384+00:00 heroku[web.1]: Starting process with command `npm start`
2017-05-05T04:02:01.390032+00:00 app[web.1]: 
2017-05-05T04:02:01.481034+00:00 app[web.1]:     at Function.Module._load (module.js:418:25)
2017-05-05T04:02:01.390047+00:00 app[web.1]: > pwa-courses@1.0.0 start /app
2017-05-05T04:02:01.481034+00:00 app[web.1]:     at Module.require (module.js:498:17)
2017-05-05T04:02:01.390048+00:00 app[web.1]: > node server.js
2017-05-05T04:02:01.481034+00:00 app[web.1]:     at require (internal/module.js:20:19)
2017-05-05T04:02:01.390049+00:00 app[web.1]: 
2017-05-05T04:02:01.481035+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:1:77)
2017-05-05T04:02:01.481027+00:00 app[web.1]: module.js:472
2017-05-05T04:02:01.481035+00:00 app[web.1]:     at Module._compile (module.js:571:32)
2017-05-05T04:02:01.481031+00:00 app[web.1]:     throw err;
2017-05-05T04:02:01.481036+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:580:10)
2017-05-05T04:02:01.481031+00:00 app[web.1]:     ^
2017-05-05T04:02:01.481036+00:00 app[web.1]:     at Module.load (module.js:488:32)
2017-05-05T04:02:01.481032+00:00 app[web.1]: 
2017-05-05T04:02:01.481036+00:00 app[web.1]:     at tryModuleLoad (module.js:447:12)
2017-05-05T04:02:01.481033+00:00 app[web.1]: Error: Cannot find module 'express'
2017-05-05T04:02:01.481033+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:470:15)
2017-05-05T04:02:01.481037+00:00 app[web.1]:     at Function.Module._load (module.js:439:3)
2017-05-05T04:02:01.495848+00:00 app[web.1]: npm ERR! errno 1
2017-05-05T04:02:01.495852+00:00 app[web.1]: npm ERR! pwa-courses@1.0.0 start: `node server.js`
2017-05-05T04:02:01.495897+00:00 app[web.1]: npm ERR! Exit status 1
2017-05-05T04:02:01.495601+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-05-05T04:02:01.496006+00:00 app[web.1]: npm ERR! 
2017-05-05T04:02:01.496080+00:00 app[web.1]: npm ERR! Failed at the pwa-courses@1.0.0 start script 'node server.js'.
2017-05-05T04:02:01.496163+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-05-05T04:02:01.496303+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the pwa-courses package,
2017-05-05T04:02:01.496305+00:00 app[web.1]: npm ERR! not with npm itself.
2017-05-05T04:02:01.496375+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-05-05T04:02:01.496492+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-05-05T04:02:01.496583+00:00 app[web.1]: npm ERR!     npm bugs pwa-courses
2017-05-05T04:02:01.496662+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-05-05T04:02:01.496736+00:00 app[web.1]: npm ERR!     npm owner ls pwa-courses
2017-05-05T04:02:01.496811+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-05-05T04:02:01.496417+00:00 app[web.1]: npm ERR!     node server.js

我已经使用了来自https://github.com/vuejs/pwa的VueJS并已经开始制作。这是 package.json。

的脚本
  "scripts": {
    "dev": "node build/dev-server.js",
    "start": "node server.js",
    "build": "node build/build.js",
    "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
    "e2e": "node test/e2e/runner.js",
    "test": "npm run unit && npm run e2e",
    "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
  },

server.js

var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');
app = express();
app.use(serveStatic(path.join(__dirname, 'dist')));
var port = process.env.PORT || 5000;
app.listen(port);
console.log('server started ' + port);

我可以在本地成功运行npm start但是在heroku中,遇到了这些错误。请帮帮我,我错过了添加的东西。

0 个答案:

没有答案