Git Product home page Git Product logo

grunt-nodemon's Introduction

Note: This is not actively maintained, please make an issue if you are interested in helping maintain this project.

grunt-nodemon

Run nodemon as a grunt task for easy configuration and integration with the rest of your workflow

NPM version Dependency Status Travis Status

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

npm install grunt-nodemon --save-dev

Then add this line to your project's Gruntfile.js gruntfile:

grunt.loadNpmTasks('grunt-nodemon');

Documentation

Minimal Usage

The minimal usage of grunt-nodemon runs with a script specified:

nodemon: {
  dev: {
    script: 'index.js'
  }
}

Usage with all available options set

nodemon: {
  dev: {
    script: 'index.js',
    options: {
      args: ['dev'],
      nodeArgs: ['--debug'],
      callback: function (nodemon) {
        nodemon.on('log', function (event) {
          console.log(event.colour);
        });
      },
      env: {
        PORT: '8181'
      },
      cwd: __dirname,
      ignore: ['node_modules/**'],
      ext: 'js,coffee',
      watch: ['server'],
      delay: 1000,
      legacyWatch: true
    }
  },
  exec: {
    options: {
      exec: 'less'
    }
  }
}

Advanced Usage

A common use case is to run nodemon with other tasks concurrently. It is also common to open a browser tab when starting a server, and reload that tab when the server code changes. These workflows can be achieved with the following config, which uses a custom options.callback function, and grunt-concurrent to run nodemon, node-inspector, and watch in a single terminal tab:

concurrent: {
  dev: {
    tasks: ['nodemon', 'node-inspector', 'watch'],
    options: {
      logConcurrentOutput: true
    }
  }
},
nodemon: {
  dev: {
    script: 'index.js',
    options: {
      nodeArgs: ['--debug'],
      env: {
        PORT: '5455'
      },
      // omit this property if you aren't serving HTML files and 
      // don't want to open a browser tab on start
      callback: function (nodemon) {
        nodemon.on('log', function (event) {
          console.log(event.colour);
        });
        
        // opens browser on initial server start
        nodemon.on('config:update', function () {
          // Delay before server listens on port
          setTimeout(function() {
            require('open')('http://localhost:5455');
          }, 1000);
        });

        // refreshes browser when server reboots
        nodemon.on('restart', function () {
          // Delay before server listens on port
          setTimeout(function() {
            require('fs').writeFileSync('.rebooted', 'rebooted');
          }, 1000);
        });
      }
    }
  }
},
watch: {
  server: {
    files: ['.rebooted'],
    options: {
      livereload: true
    }
  } 
}

Note that using the callback config above assumes you have open installed and are injecting a LiveReload script into your HTML file(s). You can use grunt-inject to inject the LiveReload script.

Required property

script

Type: String

Script that nodemon runs and restarts when changes are detected.

Options

args

Type: Array of Strings

List of arguments to be passed to your script.

nodeArgs

Type: Array of Strings

List of arguments to be passed to node. The most common argument is --debug or --debug-brk to start a debugging server.

callback

Type: Function Default:

function(nodemon) {
  // By default the nodemon output is logged
  nodemon.on('log', function(event) {
    console.log(event.colour);
  });
};

Callback which receives the nodemon object. This can be used to respond to changes in a running app, and then do cool things like LiveReload a web browser when the app restarts. See the nodemon docs for the full list of events you can tap into.

ignore

Type: Array of String globs Default: ['node_modules/**']

List of ignored files specified by a glob pattern relative to the watched folder. Here is an explanation of how to use the patterns to ignore files.

ext

Type: String Default: 'js'

String with comma separated file extensions to watch. By default, nodemon watches .js files.

watch

Type: Array of Strings Default: ['.']

List of folders to watch for changes. By default nodemon will traverse sub-directories, so there's no need in explicitly including sub-directories.

delay

Type: Number Default: 1000

Delay the restart of nodemon by a number of milliseconds when compiling a large amount of files so that the app doesn't needlessly restart after each file is changed.

legacyWatch

Type: Boolean Default: false

If you wish to force nodemon to start with the legacy watch method. See https://github.com/remy/nodemon/blob/master/faq.md#help-my-changes-arent-being-detected for more details.

cwd

Type: String

The current working directory to run your script from.

env

Type: Object

Hash of environment variables to pass to your script.

exec

Type: String

You can use nodemon to execute a command outside of node. Use this option to specify a command as a string with the argument being the script parameter above. You can read more on exec here.

Changelog

0.3.0 - Updated to nodemon 1.2.0.

0.2.1 - Updated README on npmjs.org with correct options.

0.2.0 - Updated to nodemon 1.0, added new callback option.

Breaking changes:

  • options.file is now script and is a required property. Some properties were changed to match nodemon: ignoredFiles -> ignore, watchedFolders -> watch, delayTime -> delay, watchedExtensions -> ext(now a string) to match nodemon.

0.1.2 - nodemon can now be listed as a dependency in the package.json and grunt-nodemon will resolve the nodemon.js file's location correctly.

0.1.1 - Added legacyWatch option thanks to @jonursenbach.

0.1.0 - Removed debug and debugBrk options as they are encapsulated by the nodeArgs option.

Breaking changes:

  • Configs with the debug or debugBrk options will no longer work as expected. They simply need to be added to nodeArgs.

0.0.10 - Added nodeArgs option thanks to @eugeneiiim.

0.0.9 - Fixed bug when using cwd with ignoredFiles.

0.0.8 - Added error logging for incorrectly installed nodemon.

0.0.7 - Added debugBreak option thanks to @bchu.

0.0.6 - Added env option.

0.0.5 - Added cwd option.

0.0.4 - Added nodemon as a proper dependency.

0.0.3 - Uses local version of nodemon for convenience and versioning.

0.0.2 - Removes .nodemonignore if it was previously generated and then the ignoredFiles option is removed.

0.0.1 - Added warning if nodemon isn't installed as a global module.

0.0.0 - Initial release

grunt-nodemon's People

Contributors

arty-name avatar bchu avatar chriswren avatar cmbankester avatar erunion avatar eugeneiiim avatar giggio avatar nackjicholson avatar samkelleher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-nodemon's Issues

no error in grunt, but server doesnt run

I'm testing this task with grunt nodemon -v

the output for nodemon

Running "nodemon:script" (nodemon) task
Verifying property nodemon.script exists in config...OK
Files: app.js -> script
Options: (none)

but the server doesn't come up, it just go back to bash, it works normally if i just run nodemon not from grunt.

i've tried different Gruntfile configs, starting from the minimal config from sample

nodemon: {
  dev: {
    script: 'index.js'
  }
}

Grunt-Nodemon does not launch Coffeescript

Hello,

I tried :

nodemon: {
  app: {
    options: {
      file: 'app/app.coffee',
      watchedExtensions: ['js', 'coffee'],
      watchedFolders: ['app'],
      ignoredFiles: ['node_modules/**']
    }
  }
}
grunt.registerTask('server', [
  'nodemon'
]);

But when I launch

grunt server

grunt-nodemon launch :

[nodemon] starting `node app/app.coffee`

instead of

[nodemon] starting `coffee app/app.coffee`

as it does when I launch :

nodemon app/app.coffee

This is not resolved by solution in Issue #9 because coffee is in the watched extensions.

Just solved with :

watchedExtensions: ['.js', '.coffee']

The problem is you forgot the "." in your readme

Furthermore :

watchedExtensions: ['.js']

does not work but with no watchedExtensions it does what seems to be a bug

BEWARE: this package breaks node-gyp on node 6.9

After many hours of trying to understand why node-gyp builds of various packages were failing after upgrade to node 6.9 LTS (boron), I finally found this package to be the cause. I highly recommend avoiding this package until this issue is fixed!
Node-gyp build of packages like mmmagic, bcrypt and memwatch will all fail with the mysterious error:

/usr/src/app/node_modules/.bin/touch: 1: /usr/src/app/node_modules/.bin/touch: Syntax error: "(" unexpected

For posterity and for other desperate google searchers, here is an example of a full error log:

[email protected] install /usr/src/app/node_modules/mmmagic
node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp http GET https://nodejs.org/download/release/v6.9.1/node-v6.9.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v6.9.1/node-v6.9.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v6.9.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v6.9.1/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/usr/src/app/node_modules/mmmagic/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.node-gyp/6.9.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.node-gyp/6.9.1',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=/usr/src/app/node_modules/mmmagic',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/usr/src/app/node_modules/mmmagic/build'
CC(target) Release/obj.target/libmagic/deps/libmagic/src/apprentice.o
/usr/src/app/node_modules/.bin/touch: 1: /usr/src/app/node_modules/.bin/touch: Syntax error: "(" unexpected
deps/libmagic/libmagic.target.mk:132: recipe for target 'Release/obj.target/libmagic/deps/libmagic/src/apprentice.o' failed
make: *** [Release/obj.target/libmagic/deps/libmagic/src/apprentice.o] Error 2
make: Leaving directory '/usr/src/app/node_modules/mmmagic/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.17-boot2docker
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"gyp ERR! cwd /usr/src/app/node_modules/mmmagic
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm info lifecycle [email protected]~install: Failed to exec install script

Help in upgrading from grunt-nodemon 1.2 to 2.0

I haven't been able to upgrade from grunt-nodemon 1.2 to ~2.0. Here my Gruntfile.js that works in grunt-nodemon 1.2 but not 2.0. Help?

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-env');

  grunt.initConfig({
    nodemon: {
      dev: { options: { file: "server.js" } }
    },
    env: {
      dev: { src: ".env" },
    }
  });

  grunt.registerTask('default', ['env:dev', 'nodemon']);
};

When I run grunt, both tasks execute, but nodemon doesn't start up.

I tried going with a minimal grunt-nodemon config (as denoted in the readme), but that didn't work either.

Here is my package.config

{
  "name": "sanoise",
  "version": "0.0.0-1",
  "description": "public discussions in front of audiences",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "repository": "",
  "author": "Amir Rajan",
  "license": "MIT",
  "dependencies": {
    "express": "~3.4.8",
    "ejs": "~0.8.5",
    "socket.io": "~0.9.16",
    "underscore": "~1.5.2",
    "passport": "~0.2.0",
    "passport-twitter": "~1.0.2",
    "redis": "~0.10.0",
    "install": "~0.1.7"
  },
  "subdomain": "sanoise",
  "engines": {
    "node": "0.10.x"
  },
  "devDependencies": {
    "grunt-nodemon": "~0.1.2",
    "grunt": "~0.4.2",
    "grunt-env": "~0.4.1",
    "nodemon": "~1.0.14"
  }
}

Error with 0.0.2

With this config:
nodemon: {
dev: {
options: {
file: 'server.js',
args: [],
ignoredFiles: ['public/', 'test/','util/**'],
watchedExtensions: ['js'],
// nodeArgs: ['--debug'],
delayTime: 1,
env: {
PORT: 3000
},
cwd: __dirname
}
}
},

we are having problems on OSX and Linux. Grunt stops at:
grunt
Running "jshint:all" (jshint) task

68 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...

Any idea what could be the problem?

we tried:
legacyWatch: true,
with no luck.

How can I watch just one folder?

I have a grunt task(not serve). It just need to watch one folder. But Options.watch is use to set the additional folders. And it's not beautiful if I hardcode all other folders to Options.ignore. I try to set

ignore : ['./**']

but fail. Changes still trigger restart. How should I set the Options?
There is a little question confuse me: If it's default to watch all files, what kind of folder should be added to the Options.watch?

watchedFolders/ignored options are ignored in version 0.2.0

Hi,

Since I upgraded to grunt-nodemon 0.2.0 the values passed to "watchedFolders" or "ignored" aren't being used...
No idea how this is happening.

I have the following config in my Gruntfile.js:

        nodemon: {
            server: {
                options: {
                    watchedFolders: ['<%= config.api %>', '<%= config.config %>'],
                    nodeArgs: ['--debug'],
                    delayTime: 0.1
                },
                script: 'app.js',
            }
        },

When I add folders to ignore (such as ".tmp/"), nodemon doesn't seem to do anything with it.

And the output in my terminal is the following:

[nodemon] v1.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug app.js`

So it doesn't say "watching folders: xxx, xxx" anymore..

Any idea how to solve this?

nodemon required as local dependency?

Why is nodemon required as a local dependency?

I’m currently on a project where they are using nodemon in their staging/QA environments to run the app. There is no need to make grunt anything more than a dev-dependency, except now to support the requirement to locally install it.

Nodemon throws Error: listen EADDRINUSE

I'm trying to use nodemon to have my entire workflow in one shell tab. However, it keeps throwing this error and crashing. I look it up and I've found it means that the port is in use, however I know that there is nothing else running on that port, as running the app with grunt watch works just fine. Here is my gruntfile:

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sass: {
            dist: {
                options: {
                    style: 'compressed'
                },
                files: {
                    'public/css/main.css': 'public/scss/main.scss',
                    'public/css/critical.css': 'public/scss/critical.scss'
                }
            }
        },
        uglify: {
            build: {
                src: 'public/js/main.js',
                dest: 'public/js/production.js'
            }
        },
        inline: {
            dist: {
                src: ['public/src/index.html'],
                dest: ['public/']
            }
        },
        watch: {
            all: {
                files: ['.rebooted','public/js/main.js','public/scss/*.scss','public/src/index.html'],
                tasks: ['uglify', 'sass', 'inline'],
                options: {
                    livereload: 8181
                }
            }
        },
        nodemon: {
            dev: {
                script: 'index.js',
                options: {
                    env: {
                        PORT: '8181'
                    },
                    callback: function(nodemon) {
                        nodemon.on('log', function(event) {
                            console.log(event.colour);
                        });
                        nodemon.on('config:update', function() {
                            setTimeout(function() {
                                require('open')('http://localhost:8181');
                            }, 1000);
                        });
                        nodemon.on('restart', function () {
                            setTimeout(function() {
                                require('fs').writeFileSync('.rebooted', 'rebooted');
                            }, 1000);
                        });
                    }
                }
            }
        },
        concurrent: {
            dev: {
                tasks: ['nodemon', 'watch'],
                options: {
                    logConcurrentOutput: true
                }
            }
        },
        inject: {
            single: {
                scriptSrc: 'livereload.js',
                files: {
                    'public/index.html': 'src/index.html'
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-inline');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-nodemon');
    grunt.loadNpmTasks('grunt-inject');
    grunt.loadNpmTasks('grunt-concurrent');

    grunt.registerTask('default', ['sass', 'uglify', 'inline']);
}

Here is the terminal output when running grunt concurrent

λ grunt concurrent
Running "concurrent:dev" (concurrent) task
Running "watch" task
Running "nodemon:dev" (nodemon) task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1039:14)
    at listen (net.js:1061:10)
    at Server.listen (net.js:1135:5)
    at Object.<anonymous> (R:\Documents\GitHub\Youphoria\index.js:18:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
[nodemon] app crashed - waiting for file changes before starting...
Fatal error: Cannot find module 'open'
    Warning:  Use --force to continue.

    Aborted due to warnings.

Is my gruntfile incorrect somewhere causing this to crash?

node mode infinite loop

When running grunt-nodemon I'm getting an infinite loop.

I saw that it may be an issue with the current version of nodemon.

They said the new version can be tested using

    npm install -D nodemon@dev 

Any tips on

  1. pegging grunt-nodemon to an older version of nodemon
  2. testing the new version of nodemon with grunt-nodemon
    .

Avoid multiple restart with big grunt processes

Hi,

I have a little problem with nodemon : when my watch process is launched, triggering nodemon, nodemon restart on each change, as showed in this capture :

nodemon-issue
(I have blured the name of the project which is under NDA from my client, sorry)

What can i do to avoid that ?

Thanks in advance,

new release

I've seen several recent merges that would benefit from a new patched release to NPM. Especially support for Grunt 1.0.

Do you have a timeline to cut a new release and NPM publish?

Nodemon dependency out of date

The nodemon package is out of date as a dependency. Current working version is v1.7.1 which has some dependencies that cause breakage in some scenarios.

For example:

In the event that the user tries to install grunt-nodemon as a dependency alongside mongoose, grunt-nodemon will require nodemon who requires touch. The version in the current dependency stack is v1.3.8 which brings touch 0.0.4. The current dependency is touch 1.0.0.

Adding nodemon to Gruntfile disables other tasks' ability to catch signals

I am setting up a nodejs server using grunt as the task runner, so I have many grunt tasks that do various things. Many of them handle signals like SIGINT, SIGQUIT, and SIGTERM. Until I add the line grunt.loadNpmTasks('grunt-nodemon'); to my Gruntfile, all of these signal handlers worked fine. As soon as I add that line, other grunt tasks, unrelated to nodemon, no longer handle signals properly.

For reproducing the issue, make sure the line I indicated above is commented out in your Gruntfile. You do not need to remove the initConfig info, or uninstall grunt-nodemon from node_modules. Then create a simple grunt task that handles SIGINT like so:

var done = this.async();

process.on('SIGINT', function() {
    console.log('Caught SIGINT');
    done();
});

Run that task, then press Ctrl-C to send the SIGINT signal to the process, and you should see that the task exits properly, displaying the desired text before exiting.

Now if you uncomment grunt.loadNpmTasks('grunt-nodemon'); in the Gruntfile and try to run the example task again, you will see that it no longer handles the signal properly.

Why would having grunt-nodemon affect other unrelated grunt tasks?

ignoredFiles and cwd don't work together

Setting cwd to another directory other that root starts nodemon in that directory, but .nodemonignore is still generated in the root directory, hence with this configuration, .nodemonignore is not read.

I think .nodemonignore should be generated in the cwd directory.

folder watch

Not sure if Im doing something wrong, but Im using a basic config:
nodemon: {
dev: {
script: 'server.js',
watch: ['my_modules/.js']
}
}
Still restarts the server on any root folder changes
[nodemon] v1.2.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: *.

[nodemon] starting node server.js

grunt task launch reports debugger listening but no process is listening on the reported port

I have all other tools and modules working but no matter how I try, the only way I can get a debugger listening is to modify my grunt.cmd to include --debug which results in me getting a debugger on grunt instead of my app. I suspect this issue is from a combination of your approach and Windows because I'm having the same problem with grunt-node-inspector. Below is my Gruntfile config for nodemon and my launch output.

I'd be happy to work with you in my environment using TeamViewer if you want to troubleshoot in place. I'm confirming that there is no process listening on 5858 using Windows native Resource Monitor and node is only listening on the following ports (9000 is my app): 9000, 35729 and 61750. I've tried attaching to the last 2 just in case, but neither give me a session.

Also, documentation doesn't make it clear (and it's not obvious to someone new to grunt like myself) but I found the hard way that the object in nodemon must match the grunt task name so for a long time, I wasn't even able to successfully use my options because my task wasn't called dev. Perhaps in the docs, rename "dev" to something like "yourGruntTaskName"?

nodemon: {
  dev: {
    options: {
      file: 'app.js',
      nodeArgs: ['--debug'],
      env: {
        PORT: '5858'
      }
    }
  }
}

LAUNCH OUTPUT:

C:\batchManWebService_Hapi>grunt dev
to: wrong arguments

Running "dev" task

Running "clean:server" (clean) task
Cleaning ".tmp"...OK

Running "compass:server" (compass) task
directory .tmp/styles/
   create .tmp/styles/main.css (1.379s)
Compilation took 1.381s

Running "connect:livereload" (connect) task
Started connect web server on localhost:9000.

Running "copy:dist" (copy) task
Created 1 directories, copied 3 files

Running "open:server" (open) task

Running "concurrent:devNodemon" (concurrent) task
to: wrong arguments

to: wrong arguments

to: wrong arguments

Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...Running "devtools" task
16 Dec 12:09:29 - [nodemon] v0.7.10
16 Dec 12:09:29 - [nodemon] to restart at any time, enter `rs`
16 Dec 12:09:29 - [nodemon] watching: C:\batchManWebService_Hapi
16 Dec 12:09:29 - [nodemon] starting `node --debug app.js`
debugger listening on port 5858
Your app is now running
16 Dec 12:09:29 - [nodemon] clean exit - waiting for changes before restart
>> Grunt Devtools v0.2.1 is ready! Proceed to the Chrome extension.

allow env variables to be sent when running a task

I'm using a combination of nodemon, this grunt plugin, and concurrent to start my node server on local machine.

I'm hosting my apps with Heroku, so when I deploy to their servers I have a node variable NODE_ENV set to "production". The issue is that I cannot configure the same variable locally when starting the server with concurrent.

I have found that nodemon accepts a variable / or more to be sent when starting the process: NODE_ENV=development nodemon ; but when I try:

concurrent: {
    
    observe: {
        
        tasks: [

            "NODE_ENV=development nodemon",
            "watch"
        ],
        
        options: {
            
            logConcurrentOutput: true
        }
    }
}

It's going to tell me that the task doesn't exist. Is there a way around that ?

Use this task in grunt server

I've been trying this out, but haven't come to a solid conclusion:

Is it possible to add this task to the list of tasks when grunt server is run and see the output in the terminal? I'd like to disable the grunt connect task and replace it with a nodemon task to an external server.js file. Being able to see the compass task and similar tasks run in the terminal output as well would also be awesome, but the nodemon task seems to block their execution when placed higher in the execution order, and doesn't seem to restart the server when files change either. I'm not using the loadNpmTasks function as recommended, but it doesn't seem to make a difference.

Launch two script

Hi !
How can I launch multiple nodemon process ?

When i do :

grunt.config('nodemon.hub.script','dev/serv/extend/deploy/deploy.js');
grunt.task.run('nodemon:hub');

grunt.config('nodemon.game.script','dev/serv/game/game.js');
grunt.task.run('nodemon:game');

with this standar config :

nodemon: {
          hub: {
            script: "none",
            delay:50,
            options: {
              nodeArgs: ['--debug'],
              callback: function (nodemon) {
                nodemon.on('log', function (event) {
                  console.log(event.colour);
                });

                nodemon.on('restart', function () {
                  setTimeout(function() {
                    require('fs').writeFileSync('.rebooted', 'rebooted');
                  }, 100);
                });
              },
              watch: ['./dev/serv/']
            }
          },
          game:{
            script: "none",
            delay:50,
            options: {
              nodeArgs: ['--debug'],
              callback: function (nodemon) {
                nodemon.on('log', function (event) {
                  console.log(event.colour);
                });

                nodemon.on('restart', function () {
                  setTimeout(function() {
                    require('fs').writeFileSync('.rebooted', 'rebooted');
                  }, 100);
                });
              },
              watch: ['./dev/serv/']
            }
          }
}

grunt launch only the first script :

Running "nodemon:hub" (nodemon) task
Node Inspector v0.7.4
Visit http://127.0.0.1:1333/debug?port=5858 to start debugging.
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: C:\Users\florian\Desktop\work\dev\serv/**/*
[nodemon] starting `node --debug dev/serv/extend/deploy/deploy.js`
debugger listening on port 5858

How to start another task after the nodemon server is listening?

I am using grunt task-runner in nodejs application.

I want to run another grunt task only after the server started by nodemon is listening to a port. Please note that i can't run the tasks concurrently (because i don't know in how much time server will start listening), so grunt-concurrent didn't helped.

How could i do that.?

I have the following task config with grunt-nodemon:

nodemon: {
        dev: {
            script: 'server.js',
            options: {
                // options ..
                callback : function(nodemon){
                    nodemon.on('config:update',function(){
                        console.log('reached here .. '); // this get consoled on screen
                        grunt.task.run('mynewtask');
                    });
                },
                // options ...
            }
        },
        exec: {
            options: {
                exec: 'less'
            }
        }
    }
```javascript

But nothing happens after server start listening. mynewtask does not start at all. Not even any error is shown.

Update readme?

Hello,
Just picked up the 2.0 changes and could not get restarts to work when files changed.

I was using these options from the readme file.

ext: 'js,coffee',
watch: ['server']

Changing 'server' to 'server.js' did the trick.
I also tried ext: '.js', as this is set as the default further down the page.

Does the ext option do anything and should there be dots before the file suffix.

Thanks.

Loosing application output

If I use grunt-nodemon, I loose application output. Wrong usage or real issue here?

output when using CLI:

myguestuser@360065e8fba2:/srv$ nodemon --ext js,jsx --ignore src,*.tmp,.git,.tmp/*,web_modules/*,.git/,node_modules/,bower_components/,.sass-cache/,Gruntfile.js,webpacconfig.js,webpack.dist.config.js,karma.conf.js,test --delay 800 --watch bin,lib,routes,.,models  bin/bootstrap.js 
18 Feb 20:12:59 - [nodemon] v1.3.7
18 Feb 20:12:59 - [nodemon] to restart at any time, enter `rs`
18 Feb 20:12:59 - [nodemon] watching: bin,lib,routes,.,models
18 Feb 20:12:59 - [nodemon] starting `node bin/bootstrap.js`
18 Feb 20:12:59 - [nodemon] watching 43,096 files - this might cause high cpu usage. To reduce use "--watch".
  express:application compile etag weak +0ms
  express:application compile query parser extended +2ms
  express:application compile trust proxy false +1ms
  express:application booting in development mode +0ms
Each child in an array should have a unique "key" prop. Check the renderComponent call using <Route>. See http://fb.me/react-warning-keys for more information.
express deprecated app.del: Use app.delete instead node_modules/express-namespace/index.js:58:16

And using grunt-nodemon:

myguestuser@360065e8fba2:/srv$ grunt nodemon
Running "nodemon:dev" (nodemon) task
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /srv/bin/**/* /srv/lib/**/* routes *.* /srv/models/**/*
[nodemon] starting `node bin/bootstrap.js`

grunt config:

    nodemon: {
      dev: {
        script: 'bin/bootstrap.js',
        options: {
          delay: 800,
          ext: "js,jsx",
          ignore: ["src", "*.tmp", ".git",".tmp/*", "web_modules/*", '.git/', 'node_modules/', 'bower_components/', '.sass-cache/', 'Gruntfile.js', 'webpack.config.js', 'webpack.dist.config.js', 'karma.conf.js', "test"],
          watch: ["bin", "lib", "routes", ".", "models"],
        }
      }
    },

README on npm doesn't the config schema for 0.2.0

The README in 0.2.0 release, which is what's showing up on npm, doesn't match the expected config schema for the actual 0.2.0 codebase there. Once I changed my config to match your latest non-released README from master, everything is awesome.

I looked through the closed issues, and I think that might be the source of some confusion for the simpler config errors. Possible to release a patch to npm so those match up nicely? Thanks for a great plugin!

Problems with > 0.0.09

Anytime nodemon restarts Node within Grunt, I get the error below (not terminating properly). It can be triggered by entering "rs" . If I roll back to 0.0.09, the problem goes away.

Any ideas?

Failed to open socket on port 5858, waiting 1000 ms before retrying
Server pid 66379 listening on port 3030 in development mode

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE

Error: listen EADDRINUSE

Node, express, grunt; very basic setup. From what I can ascertain, grunt-nodemon is not killing the existing node process before trying to launch the new one, thus the error below occurs:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE

I understand from nodemon doco that it sends the SIGUSR2 signal to kill the process, but from what I can tell, it is not sending it, i.e. adding the following into my module.exports section is never called:

process.on('SIGUSR2', function() {
  console.log('SIGUSR2');
});

However, if I manually launch node, and then use 'ps -aux | grep node' to find the process id, then use this command:

kill -s SIGUSR2 <process id>

The SIGUSR signal is detected by the code above. This makes me think the problem is not with my node application but that, as I mentioned above, that grunt-nodemon is not killing the process (certainly not with SIGINT, SIGINTERM, SIGUSR1 or SIGUSR2).

I tried specifying the port (3000) in the nodemon section of the gruntfile to be sure, and nothing else is running on port 3000.

This problem occurs on both Windows and Ubuntu.

I know this is not much in the way of reproducible code, much less a pull request to patch it, but I had to raise it as there is definitely an issue. I hope this can shed some light on it, because grunt-watch, grunt-concurrent and grunt-nodemon would be a fantastic combination!

I am also not sure whether any issue lies within nodemon or grunt-nodemon.. I had to start somewhere..

Thank you for your efforts with this repo.

npm will not install dependency if nodemon is already installed locally

Basically, if you try
npm install nodemon grunt-nodemon or npm install grunt-nodemon when nodemon is already present; npm will not install grunt-nodemon's dependency.

Of course, trying grunt nodemon after will trigger an error as it can't find nodemon in ./node_module/grunt-nodemon/node_modules

Unable to run in dev

Hi; wanted to run this in a dev env; but had to make a few assumptions as to how it works from your example (you only mention prod and you do not register the task): is the below correct..

When i run the below from a terminal it simply returns..

grunt nodemon

module.exports = function(grunt) {

grunt.loadNpmTasks('grunt-nodemon');

grunt.initConfig({
nodemon: {
dev: {
options: {
file: 'app.js',
args: ['development'],
ignoredFiles: ['README.md', 'node_modules/**'],
watchedExtensions: ['js', 'coffee'],
watchedFolders: ['test', 'tasks'],
debug: false,
delayTime: 1
}
}
}
});

grunt.registerTask('nodemon', ['nodemon']);
};

How to use grunt-nodemon? You do not explain it properly.

It is not clear how to use grunt-nodemon. The docs says:

Minimal Usage
The minimal usage of grunt-nodemon runs with a script specified:
nodemon: {
  dev: {
    script: 'index.js'
  }
}

But where to write it? In which file? In package.json? I wrote it in package.json but it doesn't work. And you do not explain what exactly you mean.

    "scripts": {
        "test": "grunt test",
        "start": "node index.js",
        "nodemon": {
            "dev": {
                "script": "index.js"
            }
        }
    },

Please, explain this. And also how to call the task.
npm nodemon?
nodemon grunt-nodemon?
npm script.js grunt-nodemon?
How?

high cpu usage on windows (Update nodemon to current version)

when using grunt-nodemon on Win7 64Bit I experience high cpu usage (~100%).
Watch-Option is set and respected, watching 32 files in 4 folders.

Research:
If I see it right, then currently grunt-nodemon uses nodemon in Version 1.2.x.
When I manually manipulate the grunt-nodemon package.json file to use nodemon in version ~1.3.0-5 then the cpu usage is at a minimum as expected

So I guess, it is merely an update to the package.json-file.

Thanks and regards,

Jens

watch option is ignored

It seems, that the watch option configured in "grunt-nodemon" is not
given to nodemon (it always starts by watching the default root).

Other options have not been tested.
Can this be confirmed?

Option 'cwd' doesn't work

The 'cwd'-option appears in the documentation, but there's no implementation backing it up. Neither can I find the support for changing working directory in nodemon itself. Would be an useful feature, though.

Update .nodemonignore

It would be cool if grunt-nodemon could delete and remake .nodemonignore when it's run. Right now it looks like .nodemonignore is created once and not updated when the Gruntfile settings change, and it's not totally obvious that's what's happening.

Still, grunt-nodemon is an awesome tool. Thanks for creating it! :D Before I was using shell script hacks for this. :)

Prevent nodemon from executing on first run

Currently nodemon will execute the -x commands when it is first ran. This is undesirable in some cases, and I'd like to propose a new flag to prevent this, perhaps --no-first-run. Thoughts?

Watching too many files - this might cause high cpu usage

Hi,

I have just updated to 0.3.0 and I started getting following error in the console:

[nodemon] watching 32,903 files - this might cause high cpu usage. To reduce use "--watch".

I do have watch configured:

options: {
    watch: ['backend', 'conf/app'],

So I don't know whether it was always broken without warning, or it is broken now with the upgrade.

When running nodemon through grunt-nodemon output from debug module loses color

I am using the npm debug module for debug logging and when I run nodemon itself it works fine and outputs in color. This makes it very easy to see different filters visually.

When I run how I expect is the same way using grunt and grunt-nodemon the color output is lost. Is there a way to get it back?

Here is an example:
example console output

Here is my Gruntfile.js: http://pastebin.com/6ityXi8v

I'm running using cygwin on Windows 8.1 with the following dependencies:
$ npm list --depth=0
[email protected] D:\Dev\NodeJs\spell-gen
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.