blai / grunt-express

Start an Express.js web server using grunt.js
MIT License
254 stars 41 forks source link

Adding server property to options causes error #71

Closed mitchellmc closed 10 years ago

mitchellmc commented 10 years ago

Hi,

First of all - Ill go ahead and apologize if this is a setup or problem caused by me not reading the documentation properly.

This issue occurs on the the angular ng-boilerplate kickstarter template. I’m using the yeoman ngbp located here [ https://www.npmjs.org/package/generator-ngbp ] . I’ve attached a barebones project generated with this generator [ https://www.dropbox.com/s/ogvhnte57b6rxhm/ngbp2.zip?dl=0 ]. (Please run 'npm install' after unzipping the directory - then 'grunt watch')

Problem is that when I add a server file to the express options, I get:

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

util.js:35 var str = String(f).replace(formatRegExp, function(x) {

Here are the changes to the stock ngbp ng-boilerpate kickstarter project.

Add 2 files (for two different server options - see below for when they are used): - expressServer.js


var express = require('express')
var app = express()

app.use(express.static('public'));

app.get('/api', function (req, res) {
    res.send('Hello World!')
})

var server = app.listen(3000, function () {

    var host = server.address().address
    var port = server.address().port

    console.log('Example app listening at http://%s:%s', host, port)

})

-expressServer2.js


var express = require('express');
var app = express();

app.get('/api', function (req, res) {
    res.send('Hello World!');
})

module.exports = app;

Here are the changes to the Gruntfile that I’ve tried:

1.  Add server property to options (used with expressServer2)
         express: {
            devServer: {
                options: {
                    port: 9000,
                    hostname: 'localhost',
                    serverreload: false,
                    bases: 'build',
                    livereload: true,
                    server: path.resolve('./expressServer2.js')
                }
            }
        },
2.  remove grunt-express options altogether and specify path to a server file (used with expressServer.js)
    express: {
            devServer: {
                server: path.resolve('./expressServer.js')
            }
        },

Both of these result in the error above. I’ve looked at the angular template project that is linked on the main github page, and copied the express options from that project into this project and still resulted in the same error. Any help would be appreciated.