Search code examples
node.jsexpressmean-stacknodemon

Launch Multiple Express Apps Using Nodemon from Same Path


How can I launch different Express apps from the same root folder? It is acceptable to use multiple terminal windows. I would love to use nodemon with arguments:

nodemon 'landing'
nodemon NODE_APP='app02'
NODE_APP='app02' nodemon

I am currently using node directly. This works but does not give me the ability to watch the folders:

NODE_APP='app02' node ./server/server.js

Unfortunately, I cannot find any combination for nodemon that allows this.

As you can see from my folder structure, all server resources are shared:

client
    common           <- Express static path 'common'
        assets
        directives
        modules
        vendor
    landing          <- App 01
        modules      <- Modules specific to App 01.
        app.js
        index.html
    signup           <- App 02
        modules      <- Modules specific to App 02.
        app.js
        index.html
    members          <- App 03
        modules      <- Modules specific to App 03.
        app.js
        index.html
server
    config           <- Config sets port & 'public' path to app folder.
    models           <- Common to all apps.
    routes           <- Common to all apps.
    app.js
    server.js
gruntfile.js
nodemon.json
package.json

Solution

  • Just replace nodemon where you are using node. So, instead of this:

    NODE_APP='app02' node ./server/server.js
    

    ... use this ...

    NODE_APP='app02' nodemon ./server/server.js