Sunday 21 May 2017

Node.js app deploy in heroku

I have the following file structure of my MEAN app:

root
|---> public
      |----> css
      |----> js
              |----> controller
              |----> app.js
      |----> views
      |----> index.html

|---> app
      |----> server.js
|---> node_modules
|---> bower_components
|---> gulpfile.js
|---> Procfile

In this app, I run public/index.html using gulp,

gulpfile.js:

var gulp = require('gulp');
var browserSync = require('browser-sync');
var server = require('gulp-live-server');


gulp.task('server', function() {
     live = new server('app/server.js');
     live.start();
})

gulp.task('serve', ['server'], function() {
   browserSync.init({
      notify: false,
      port: process.env.PORT || 8080,
      server: {
        baseDir: ['public'],
        routes: {
            '/bower_components': 'bower_components'
        }
      }
   });


    gulp.watch(['public/**/*.*'])
        .on('change', browserSync.reload);
});

Then communicate with app using REST API. This is working in local machine. I have uploaded this project into heroku.

My Procfile:

web: node node_modules/gulp/bin/gulp serve

But It shows error. I have the following error into heroku logs

2017-05-21T16:26:57.305350+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myapp.herokuapp.com request_id=some-request-id fwd="fwd-ip" dyno= connect= service= status=503 bytes= protocol=https

2017-05-21T15:53:50.942664+00:00 app[web.1]: Error: Cannot find module '/app/node_modules/gulp/bin/gulp'

Any suggestion? Thanks in Advance.



via user2013

No comments:

Post a Comment