最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Heroku Deploy Error: Cannot get Node App running after Deploy : Cannot find module 'appweb.js' - St

programmeradmin0浏览0评论

I have a node.js app using Express and MongoDB (mongoose). It runs perfectly fine locally. I deployed it to heroku seemingly without a problem, but when I try to actually launch the app it crashes. The heroku log says this: Error: Cannot find module '/app/web.js'

I am new to this, so any help would be greatly appreciated. Thanks! App will help my Type 1 Diabetic daughter.

package.json:

    {
  "name": "projectglu",
  "version": "0.0.0",
  "dependencies": {
    "express": "~3.4.3",
    "lodash": "~2.4.1",
    "mongoose": "~3.8.8",
    "connect-mongo": "~0.4.0",
    "passport": "~0.2.0",
    "passport-local": "~0.1.6",
    "ejs": "~0.8.4"
  },
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-autoprefixer": "~0.4.0",
    "grunt-bower-install": "~0.7.0",
    "grunt-concurrent": "~0.4.1",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-coffee": "~0.7.0",
    "grunt-contrib-pass": "~0.6.0",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-copy": "~0.4.1",
    "grunt-contrib-cssmin": "~0.7.0",
    "grunt-contrib-htmlmin": "~0.1.3",
    "grunt-contrib-imagemin": "~0.5.0",
    "grunt-contrib-jshint": "~0.7.1",
    "grunt-contrib-uglify": "~0.2.0",
    "grunt-contrib-watch": "~0.5.2",
    "grunt-google-cdn": "~0.2.0",
    "grunt-newer": "~0.5.4",
    "grunt-ngmin": "~0.0.2",
    "grunt-rev": "~0.1.0",
    "grunt-svgmin": "~0.2.0",
    "grunt-usemin": "~2.0.0",
    "jshint-stylish": "~0.1.3",
    "load-grunt-tasks": "~0.2.0",
    "time-grunt": "~0.2.1",
    "grunt-express-server": "~0.4.5",
    "grunt-open": "~0.2.0",
    "connect-livereload": "~0.3.0",
    "karma-ng-scenario": "~0.1.0",
    "grunt-karma": "~0.6.2",
    "karma-firefox-launcher": "~0.1.3",
    "karma-script-launcher": "~0.1.0",
    "karma-html2js-preprocessor": "~0.1.0",
    "karma-jasmine": "~0.1.5",
    "karma-chrome-launcher": "~0.1.2",
    "requirejs": "~2.1.10",
    "karma-requirejs": "~0.2.1",
    "karma-coffee-preprocessor": "~0.1.2",
    "karma-phantomjs-launcher": "~0.1.1",
    "karma": "~0.10.9",
    "karma-ng-html2js-preprocessor": "~0.1.0",
    "grunt-mocha-test": "~0.8.1",
    "supertest": "~0.8.2",
    "should": "~2.1.0",
    "grunt-env": "~0.4.1",
    "grunt-node-inspector": "~0.1.3",
    "grunt-nodemon": "~0.2.0",
    "open": "~0.0.4"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test"
  }
}

I have a node.js app using Express and MongoDB (mongoose). It runs perfectly fine locally. I deployed it to heroku seemingly without a problem, but when I try to actually launch the app it crashes. The heroku log says this: Error: Cannot find module '/app/web.js'

I am new to this, so any help would be greatly appreciated. Thanks! App will help my Type 1 Diabetic daughter.

package.json:

    {
  "name": "projectglu",
  "version": "0.0.0",
  "dependencies": {
    "express": "~3.4.3",
    "lodash": "~2.4.1",
    "mongoose": "~3.8.8",
    "connect-mongo": "~0.4.0",
    "passport": "~0.2.0",
    "passport-local": "~0.1.6",
    "ejs": "~0.8.4"
  },
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-autoprefixer": "~0.4.0",
    "grunt-bower-install": "~0.7.0",
    "grunt-concurrent": "~0.4.1",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-coffee": "~0.7.0",
    "grunt-contrib-pass": "~0.6.0",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-copy": "~0.4.1",
    "grunt-contrib-cssmin": "~0.7.0",
    "grunt-contrib-htmlmin": "~0.1.3",
    "grunt-contrib-imagemin": "~0.5.0",
    "grunt-contrib-jshint": "~0.7.1",
    "grunt-contrib-uglify": "~0.2.0",
    "grunt-contrib-watch": "~0.5.2",
    "grunt-google-cdn": "~0.2.0",
    "grunt-newer": "~0.5.4",
    "grunt-ngmin": "~0.0.2",
    "grunt-rev": "~0.1.0",
    "grunt-svgmin": "~0.2.0",
    "grunt-usemin": "~2.0.0",
    "jshint-stylish": "~0.1.3",
    "load-grunt-tasks": "~0.2.0",
    "time-grunt": "~0.2.1",
    "grunt-express-server": "~0.4.5",
    "grunt-open": "~0.2.0",
    "connect-livereload": "~0.3.0",
    "karma-ng-scenario": "~0.1.0",
    "grunt-karma": "~0.6.2",
    "karma-firefox-launcher": "~0.1.3",
    "karma-script-launcher": "~0.1.0",
    "karma-html2js-preprocessor": "~0.1.0",
    "karma-jasmine": "~0.1.5",
    "karma-chrome-launcher": "~0.1.2",
    "requirejs": "~2.1.10",
    "karma-requirejs": "~0.2.1",
    "karma-coffee-preprocessor": "~0.1.2",
    "karma-phantomjs-launcher": "~0.1.1",
    "karma": "~0.10.9",
    "karma-ng-html2js-preprocessor": "~0.1.0",
    "grunt-mocha-test": "~0.8.1",
    "supertest": "~0.8.2",
    "should": "~2.1.0",
    "grunt-env": "~0.4.1",
    "grunt-node-inspector": "~0.1.3",
    "grunt-nodemon": "~0.2.0",
    "open": "~0.0.4"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test"
  }
}
Share Improve this question asked Mar 15, 2014 at 10:59 user3416321user3416321 411 silver badge3 bronze badges 1
  • 2 Not the information that is needed. Try posting your "app.js" file from the root of your project in your question instead. Or better yet, just the lines around where you are calling/loading/requiring '/app/web.js' – Neil Lunn Commented Mar 15, 2014 at 11:22
Add a ment  | 

2 Answers 2

Reset to default 3

More clearly the problem may be when you create the Procfile from Heroku website example you are cutting and pasting "web: node web.js" which basically tells heroku which file is your entry point. You probably have a different entry point like say .. server.js so swap out "web: node web.js" with "web: node server.js" to solve your problem.

There is a variety of issues that can be causing this.

Please check that you have added your 'Procfile'.Use a Procfile, a text file in the root directory of your application, to explicitly declare what mand should be executed to start a web dyno. In this case, you simply need to execute the Node script using node.

Here’s an example Procfile:

web: node web.js

Another culprit could be a misconfigured environment variable, NODE_ENV. Personally, manding Heroku to set NODE_ENV=production helped me resolved a Cannot find module error I experienced. When you do this replace myapp with your Heroku app name.

heroku labs:enable user-env-pile -a myapp heroku config:set NODE_ENV=production

If this fails to solve your issue move the packages declared in devDependencies over to dependencies just to mitigate the NODE_ENV issue.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论