EzDevInfo.com

nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development nodemon

Nodemon with IcedCoffeeScript

First of all, I install nodemon globally:

npm install -g nodemon

Then I try to start my apllication using the following command:

nodemon app.iced

And I get such error: "SyntaxError: Unexpected token ILLEGAL". However, I can run my application without nodemon without any errors:

iced --nodejs --debug app.iced

What the problem is?


Source: (StackOverflow)

Sublime Text3 console with nodemon

I can successfully use the node in the console of the sublime text 3 editor. I try to use nodemon to make it faster for me to run it each time I save the file.

I go tools-> build system and type this:

{
  "cmd": [ "/usr/local/bin/nodemon", "$file" ],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js"
}

but I get the following error:

env: node: Argument list too long
[Finished in 25.7s with exit code 126]
[cmd: ['/usr/local/bin/nodemon', '/Users/x/Documents/MSCS/p2/v4/app.js']]
[dir: /Users/x/Documents/MSCS/p2/v4]
[path: /usr/bin:/bin:/usr/sbin:/sbin] 

And in the console here is what happens:

x$> nodemon --v app.js

env: node: Argument list too long

Thanks for help:)


Source: (StackOverflow)

Advertisements

compile scss with nodemon and node-sass

I'm playing around with node.js, express and node-sass and watching for file changes with nodemon.

I added this bit to the app.js to compile the scss (according to the node-sass docs) but it's not doing anything. I would like for the sass to compile when nodemon runs app.js every time I make changes to the project.

I'm not sure if it will even work with nodemon like this but just running node app.js in the console without nodemon does nothing so it must be something I'm doing wrong.

APP.JS FILE

/**
* Module dependencies.
*/

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var sass = require('node-sass')

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.favicon(__dirname + '/public/favicon.ico'));
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(sass.middleware({
src: __dirname + '/public/scss',
dest: __dirname + '/public/css',
debug: true,
outputStyle: 'compressed'
}));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});

thanks for any help.


Source: (StackOverflow)

Nodemon is losing console output when the process is crashing

I am not sure if this is purely Windows issue. I don't have option to test anywhere else. Given this really simple code (Coffeescript):

console.log('Calling console.log')
console.error('Calling console.error')
console.log('Calling console.log second time - fails')
console.error('Calling console.error second time - fails')
nonexisting.throwError()

Running it directly with coffee app.coffee it works just fine and I get this:

Calling console.log
Calling console.error
Calling console.log second time - fails
Calling console.error second time - fails
ReferenceError: nonexisting is not defined
....

However running nodemon app.coffee gives me just this:

17 Mar 20:38:56 - [nodemon] starting `coffee.cmd server.coffee`
Calling console.log
Calling console.error
17 Mar 20:38:56 - [nodemon] app crashed - waiting for file changes before starting...

Not only there isn't exception info at all, but also later log messages are swallowed for some reason. In more complex scenario I have no method to actually find the reason of crash. I tried to debug, but everything seems fine, console.log/error is called, but it's just not displayed for some reason. And exception is caught by Coffeescript and send directly to stderr.

I wanted to use debug utility to have nice verbose output during development in the console and make it easier to find issues. But with this troublemaker it's not possible. Once uncaught exception occurs, I have to stop nodemon and run whole thing manually to find the error. All the elegance of the solution goes away with this :(

Anyone have idea what could be causing this and if there is some possible solution ?

Windows 7 64bit Node 0.10.26 Nodemon 1.0.15 Coffeescript 1.7.1


Source: (StackOverflow)

Nodeclipse debugger ignoring breakpoints

I'm using Nodeclipse 0.10 with nodemon, but when I try to debug my script it doesn't stop at any of my breakpoints. I've already seen this and this answer but it hasn't helped.

Occasionally, it will stop on the first line of nodemon, other times it gives me a timeout error from the V8 VM, and sometimes it doesn't do anything at all.

Here's what I've tried so far:

  1. I tried both the "Node application" and the "Node with monitor", neither one works.
  2. Removed nodemon from the preferences page, but then Eclipse just complains it's missing the nodemon path and won't start my script (even if I select "Node application")
  3. Ran node --debug-brk=5858 from the command line and then tried to attach the Eclipse debugger to it
  4. Tried launching the debug from the toolbar button (my personal default) as well as from context menu after right clicking the script file - that just makes it stop on the module.exports line of the script
  5. Ran eclipse --clean

None of it works. As a side note, I did not install Nodeclipse into a new Eclipse environment when I installed it, because it took me a long time to configure my existing one to where I liked it, and I'd rather be able to keep that.

Anyone dealt with this issue before?


Source: (StackOverflow)

npm scripts nodemon - watching js and scss files for changes

I'm experimenting with setting up a dev environment to use NPM only, without the use of grunt.js or bower.js.

I followed this tutorial: http://beletsky.net/2015/04/npm-for-everything.html

I'm using nodemon to watch my .js and .scss files for changes which restarts the node server. So in my package.json file, under scripts I have

scripts:

"watch-js": "nodemon -e js --watch public/js -x \"npm run build-js\"",

"watch-sass": "nodemon -e scss --watch public/sass -x \"npm run build-sass\"",

"watch": "npm run watch-js & npm run watch-sass"

But when I run npm run watch it only watches for the public/js files to change. And it triggers a build accordingly.

But it won't watch for the sass files.

Versions: node v0.10.36 nodemon v1.4.1

I also include a build script which if I run compiles the sass to css, so my build-sass script should be ok

"build": "npm run build-js & npm run build-sass",
"watch": "npm run watch-js & npm run watch-sass"

Source: (StackOverflow)

Gruntjs with grunt-nodemon, watch and jshint

im trying to run GruntJS with those 3 plugins so it can watch for changes and first: lint the file and then reaload express server. My problem whith the config below is that if jshint lint the file, nodemon doesen't run and viceversa.

// Gruntfile.js

// our wrapper function (required by grunt and its plugins)
// all configuration goes inside this function
module.exports = function(grunt) {

  // ===========================================================================
  // CONFIGURE GRUNT ===========================================================
  // ===========================================================================
  grunt.initConfig({

    // get the configuration info from package.json ----------------------------
    // this way we can use things like name and version (pkg.name)
    pkg: grunt.file.readJSON('package.json'),

    // all of our configuration will go here

    // configure jshint to validate js files -----------------------------------
  jshint: {
      options: {
        reporter: require('jshint-stylish') // use jshint-stylish to make our errors look and read good
      },

    // when this task is run, lint the Gruntfile and all js files in src
      build: ['Grunfile.js', 'routes/*.js']
    },

    watch: {

      // for scripts, run jshint and uglify
      scripts: {
        files: 'routes/*.js',
        tasks: ['jshint']
      }
    },

    concurrent: {
      dev: {

        tasks: ['jshint', 'nodemon', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    }, // concurrent

    nodemon: {
      dev: {
        script: './server.js'
      }
    } // nodemon


  });

  // ===========================================================================
  // LOAD GRUNT PLUGINS ========================================================
  // ===========================================================================
  // we can only load these if they are in our package.json
  // make sure you have run npm install so our app can find these
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-nodemon');


      grunt.registerTask('default', '', function() {
    var taskList = [
        'jshint',
        'nodemon',
        'watch'
    ];
    grunt.task.run(taskList);
});

};

EDIT (clarification):

The first time that I runt "grunt" jshint lint the files, then nodemon start and jshint doesen't lint anymore. Output:

grunt
Running "default" task

Running "jshint:build" (jshint) task

✔︎ No problems


Running "nodemon:dev" (nodemon) task
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./server.js`
Express server listening on port 3000

Source: (StackOverflow)

Nodeclipse + nodemon error

When I try to run an express app in nodeclipse, it gives me the error,

23 Jan 11:58:04 - [33m[nodemon] v1.0.13[39m

23 Jan 11:58:04 - [33m[nodemon] to restart at any time, enter rs[39m

23 Jan 11:58:04 - [33m[nodemon] watching: .[39m

23 Jan 11:58:04 - [32m[nodemon] starting node /home/rdteam/workspace/NedvedNodeExpressTest/app.js[39m

[31m[nodemon] unable to run executable: "node"[39m

However, when I run from command line that node /home/rdteam/workspace/NedvedNodeExpressTest/app.js or nodemon /home/rdteam/workspace/NedvedNodeExpressTest/app.js

both work without problem.

Pls help.

Regards Hammer


Source: (StackOverflow)

How to use nodemon with JSX?

I can compile and run my JSX app with one command:

jsx app.jsx | node

But I also want my server to automatically restart every time I modify app.jsx. I can do that with nodemon, but I can't quite figure out how to get nodemon to run my script through the JSX compiler beforehand.

I've got a nodemon.json file set up like this:

{
    "execMap": {
        "js": "node",
        "jsx": "jsx {{filename}} | node"
    },
    "ext": "js jsx",
    "ignore": [
        ".hg",
        "node_modules",
        ".idea"
    ],
    "verbose": true
}

But when I run nodemon it tells me:

8 Feb 21:58:48 - [nodemon] starting `jsx app.jsx | node`
8 Feb 21:58:48 - [nodemon] child pid: 10976
'\"jsx app.jsx | node\"' is not recognized as an internal or external command,
operable program or batch file.

Which is odd, because that command works verbatim when I paste it directly into my terminal.

Is there any way I get nodemon to run my JSX files?


Source: (StackOverflow)

Why can't i npm install nodemon or supervisor on OSX 10.8.4?

I'm just trying to install nodemon or supervisor using terminal, and I keep getting this error which I don't understand. I tried running as the administrator with sudo npm install supervisor -g which seemed to work, but than didn't when i deleted/added some js code. Any ideas?

Squirrels-MacBook-Air:lesson7_examples Squirrel$ npm install nodemon -g
npm http GET https://registry.npmjs.org/nodemon
npm http 304 https://registry.npmjs.org/nodemon
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/nodemon',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/nodemon',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.4.1
npm ERR! command "node" "/usr/local/bin/npm" "install" "nodemon" "-g"
npm ERR! cwd /Users/Squirrel/Documents/Code/Memry/Memry_Mongoose
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! fstream_path /usr/local/lib/node_modules/nodemon
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/Squirrel/Documents/Code/Memry/Memry_Mongoose/npm-debug.log
npm ERR! not ok code 0
Squirrels-MacBook-Air:lesson7_examples Squirrel$ 

P.S. I'm running this on a pre-existing template and my dependencies are

  "dependencies": {
    "mongoose": "~3.6.15",
    "express": "~3.3.4",
    "jade": "~0.34.1",
    "email-validator": "~0.1.2"
  }

When I tried sudo this is what happened:

sudo npm install supervisor -g --save 
Password:
npm http GET https://registry.npmjs.org/supervisor
npm http 304 https://registry.npmjs.org/supervisor
/usr/local/bin/node-supervisor -> /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js
/usr/local/bin/supervisor -> /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js
supervisor@0.5.6 /usr/local/lib/node_modules/supervisor

Which seemed to work. But than in the application code I began to add and delete javascript and click save, yet the effects wouldn't take place unless I restarted the server within terminal.


Source: (StackOverflow)

gulpfile browsersync nodemon too much ram

My gulpfile is not functioning how I'd like. When I run the default task gulp my browser is launched but hangs at waiting for localhost... in the lower left corner. If I refresh then the server works as expected. I'd also like to edit my code and get the updates showing in my browser. This feature works but gulp grows to ~300mb of ram after developing for a while.

'use strict';
process.env.DEBUG = process.env.DEBUG || 'r3dm:*';
var gulp = require('gulp'),

    // ## Style
    concat = require('gulp-concat'),
    stylus = require('gulp-stylus'),
    swiss = require('kouto-swiss'),
    mincss = require('gulp-minify-css'),

    // ## Bundle
    browserify = require('browserify'),
    watchify = require('watchify'),
    envify = require('envify/custom')({ NODE_ENV: 'development' }),
    uglifyify = require('uglifyify'),
    bundleName = require('vinyl-source-stream'),
    //brfs = require('brfs'),

    // ## utils
    plumber = require('gulp-plumber'),
    util = require('gulp-util'),
    noopPipe = util.noop,
    //logPipe = util.log,
    watch = require('gulp-watch'),
    yargs = require('yargs').argv,
    debug = require('debug')('r3dm:gulp'),

    // ## min
    imagemin = require('gulp-imagemin'),
    //pngcrush = require('imagemin-pngcrush'),

    // ## Serve/Proxy/Reload
    nodemon = require('gulp-nodemon'),
    sync = require('browser-sync'),
    reload = sync.reload,

    // ## React
    react = require('gulp-react'),

    // ## production?
    production = yargs.p;

var paths = {
  main: './client.js',
  jsx: './components/**/**.jsx',
  stylusMain: './components/app.styl',
  stylusAll: './components/**/*.styl',
  css: './public/css/',
  server: './server.js',
  serverIgnore: [
    'gulpfile.js',
    'public/',
    'components/**/*.styl',
    'bower_components/',
    'node_modules/'
  ],
  publicJs: './public/js'
};

var watching = false;
var reloadDelay = 6500;

if (production) {
  // ## Set with `-p`
  console.log('\n', 'Production mode set', '\n');
}

gulp.task('stylus', function() {
  return gulp.src(paths.stylusMain)
    .pipe(plumber())
    .pipe(stylus({
      use: [
        swiss()
      ],
      'include css': true
    }))
    .pipe(concat('main.css'))
    .pipe(production ? mincss() : noopPipe())
    .pipe(gulp.dest(paths.css));
});

gulp.task('jsx', function() {
  return gulp.src('./components/**/*.jsx')
    .pipe(react())
    .pipe(gulp.dest('./components'));
});

gulp.task('jsx-watch', function() {
  return gulp.src(paths.jsx)
    .pipe(watch(paths.jsx))
    .pipe(react({
      harmony: true
    }))
    .pipe(gulp.dest('./components'));
});

gulp.task('bundle', function(cb) {
  browserifyCommon(cb);
});

gulp.task('sync', ['bundle', 'stylus', 'server'], function() {
  sync.init(null, {
    proxy: 'http://localhost:9000',
    logLeval: 'debug',
    files: [
      'public/**/*.*',
      '!public/js/bundle.js'
    ],
    port: 9002,
    open: true,
    reloadDelay: reloadDelay
  });
});

gulp.task('server', function(cb) {
  var called = false;
  nodemon({
    script: paths.server,
    ext: '.js',
    ignore: paths.serverIgnore,
    env: {
      'NODE_ENV': 'development',
      'DEBUG': 'r3dm:*'
    }
  })
    .on('start', function() {
      if (!called) {
        called = true;
        setTimeout(function() {
          cb();
        }, reloadDelay);
      }
    })
    .on('restart', function(files) {
      if (files) {
        debug('Files that changed: ', files);
      }
      setTimeout(function() {
        debug('Restarting browsers');
        reload();
      }, reloadDelay);
    });
});

gulp.task('watch', function() {
  gulp.watch(paths.stylusAll, ['stylus']);
});

gulp.task('setWatch', function() {
  watching = true;
});

gulp.task('image', function() {
  gulp.src('images/**/*')
    .pipe(imagemin({
      progressive: true,
      optimizationLevel: 2
    }))
    .pipe(gulp.dest('public/images'));
});

gulp.task('default', [
  'setWatch',
  'jsx-watch',
  'bundle',
  'stylus',
  'server',
  'sync',
  'watch'
]);

function browserifyCommon(cb) {
  cb = cb || noop;
  var config;

  if (watching) {
    config = {
      basedir: __dirname,
      debug: true,
      cache: {},
      packageCache: {}
    };
  } else {
    config = {
      basedir: __dirname
    };
  }

  var b = browserify(config);
  b.transform(envify);
  //b.transform(brfs);

  if (!production) {
    debug('Watching');
    b = watchify(b);
    b.on('update', function() {
      bundleItUp(b);
    });
  }

  if (production) {
    debug('Uglifying bundle');
    b.transform({ global: true }, uglifyify);
  }

  b.add(paths.main);
  bundleItUp(b);
  cb();
}

function bundleItUp(b) {
  debug('Bundling');
  return b.bundle()
    .pipe(plumber())
    .pipe(bundleName('bundle.js'))
    .pipe(gulp.dest(paths.publicJs));
}

function noop() { }

update: It may not be my gulpfile. I waited patiently and it eventually loads my app's root page. Here's my server.js file

'use strict';
require('dotenv').load();
require('newrelic');
var express = require('express'),
    app = express(),
    keystone = require('keystone'),
    mongoose = require('mongoose'),

    // ## Util
    debug = require('debug')('r3dm:server'),
    utils = require('./utils/utils'),

    // ## React
    React = require('react'),
    Router = require('./components/Router'),
    state = require('express-state'),

    // ## Flux
    Fetcher = require('fetchr'),
    mandrillServ = require('./services/mandrill'),
    blogServ = require('./services/blog'),
    ContextStore = require('./components/common/Context.store'),
    RouterStateAction = require('./components/common/RouterState.action'),

    // ## Express/Serve
    morgan = require('morgan'),
    serve = require('serve-static'),
    favicon = require('serve-favicon'),
    body = require('body-parser'),
    multer = require('multer'),
    compress = require('compression'),
    cookieParser = require('cookie-parser'),
    session = require('express-session'),
    flash = require('connect-flash'),
    helmet = require('helmet');

// ## State becomes a variable available to all rendered views
state.extend(app);
app.set('state namespace', 'R3DM');

app.set('port', process.env.PORT || 9000);
app.set('view engine', 'jade');
app.use(helmet());
app.use(morgan('dev'));
app.use(favicon(__dirname + '/public/images/favicon.ico'));
app.use(cookieParser('12345'));
app.use(body.urlencoded({ extended: false }));
app.use(body.json());
app.use(multer());
app.use(compress());
app.use(flash());
app.use(session({
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: true
}));

// ## Fetcher middleware
Fetcher.registerFetcher(mandrillServ);
Fetcher.registerFetcher(blogServ);
app.use('/api', Fetcher.middleware());

keystone.app = app;
keystone.mongoose = mongoose;
keystone.init({
  'cookie secret': '12345',
  'auth': true,
  'user model': 'User',
  'mongo': process.env.MONGO_URI,
  'session': true
});

keystone.import('models');
keystone.static(app);
keystone.routes(app);
keystone.mongoose.connect(keystone.get('mongo'));

app.use(serve('./public'));

app.get('/500', function(req, res) {
  res.render('500');
});

app.get('/emails/:name', function(req, res) {
  var locals = {},
      name = req.params.name,
      nameArr;

  nameArr = name
    .split(' ')
    .map(function(_name) {
      _name = _name.replace(/[^A-Za-z_'-]/gi, '');
      _name = utils.capitalize(_name);
      return _name;
    });

  locals.name = nameArr[0];
  res.render('email/greet', locals);
});

app.get('/*', function(req, res, next) {
  debug('req', req.path);
  debug('decode req', decodeURI(req.path));
  Router(decodeURI(req.path))
    .run(function(Handler, state) {
      Handler = React.createFactory(Handler);
      debug('Route found, %s ', state.path);

      var ctx = {
        req: req,
        res: res,
        next: next,
        Handler: Handler,
        state: state
      };

      debug('Sending route action');
      RouterStateAction(ctx);
    });
});

// Use a hot observable stream for requests
var hotObservable = ContextStore.publish();

// Run on next sequence
hotObservable.subscribe(function(ctx) {
  if (!ctx.Handler) { return debug('no handler'); }
  debug('rendering react to string', ctx.state.path);
  var html = React.renderToString(ctx.Handler());
  debug('rendering jade');

  ctx.res.render('layout', { html: html }, function(err, markup) {
    if (err) { return ctx.next(err); }

    debug('Sending %s', ctx.state.path);
    return ctx.res.send(markup);
  });
});

// Start listening listening to observable sequence;
hotObservable.connect();

app.use(function(req, res) {
  res.status(404);
  res.render(404);
});

app.use(function(err, req, res, next) { //jshint ignore:line
  debug('Err: ', err);
  res
    .status(500)
    .send('Something went wrong');
});

// keystone.start();
app.listen(app.get('port'), function() {
  debug('The R3DM is go at: ' + app.get('port'));
  debug(new Date());
});

line debug('req', req.path); is eventually reached after ~120 seconds. But if I refresh when the tab is first opened it loads immediately.

update 2: I was able to fix the initial loading issue by increading the dealy to 6500ms. Now I need to find what's causing the memory leak.


Source: (StackOverflow)

How do I get node-inspector to run with foreman and nodemon?

I have my heroku config vars in my .env file, so I have to use foreman to run my app locally. I need to debug using node-inspector, and I would like to not have to restart my app manually, so I would also like to use nodemon.

How do I use nodemon, node-inspector and foreman together?


Source: (StackOverflow)

nodemon not found in npm

i have a problem, nodemon not run in the npm script,
but if outside the npm script, nodemon running normally.

$ nodemon server.js
14 Feb 22:59:51 - [nodemon] v1.3.7
14 Feb 22:59:51 - [nodemon] to restart at any time, enter `rs`
14 Feb 22:59:51 - [nodemon] watching: *.*
14 Feb 22:59:51 - [nodemon] starting `node server.js`

if in npm script

package.json

{
...
  "scripts": {
    "start": "nodemon server.js"
  }
}

run npm script

$ npm start
> aaa@0.0.1 start /home/akul/Documents/aaa
> nodemon server.js

sh: 1: nodemon: not found

npm ERR! Linux 3.13.0-45-generic
npm ERR! argv "node" "/home/akul/npm-global/bin/npm" "start"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.0
npm ERR! code ELIFECYCLE
npm ERR! aaa@0.0.1 start: `nodemon server.js`
npm ERR! Exit status 127
npm ERR! 
npm ERR! Failed at the aaa@0.0.1 start script 'nodemon server.js'.
npm ERR! This is most likely a problem with the aaa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nodemon server.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls aaa
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/akul/Documents/aaa/npm-debug.log

I've been looking for a solution, but did not meet


Source: (StackOverflow)

node js os.networkInterfaces() not returning any results when called through docker entrypoint on AWS

I have node.js running inside a docker container. When I start docker, it then calls a script that calls node.js (or nodemon) to start.

Inside that node.js one of the first things it does is look for it's IP via

var ifaces = os.networkInterfaces();

But it doens't work all the time, for reasons that mystify me:

  1. AWS+Docker+manualstart node = YES!
  2. AWS+Docker+autostart nodemon= YES
  3. AWS+Docker+autostart node = NO

as 1, and 3 use identical plain commands my best guess is that docker is starting it before the network has been started. So either I can have the init script start the network earlier or poll until something shows up. Does anybody know the linux command to start the network set the ip?


Source: (StackOverflow)

Concurrently Run `watch` & `nodemon` with Grunt

I'm just getting started with Grunt and would like to run grunt-contrib-watch [GitHub page] to lint my JavaScript every time a file is modified (with grunt-contrib-jshint [GitHub page]) and run grunt-nodemon [GitHub page] too, concurrently using grunt-concurrent [GitHub page].

As I understand (which I evidently don't) my Gruntfile should:

  1. Run concurrent by default
  2. concurrent runs watch
  3. watch runs jshint every time a file is modified

Gruntfile.js

module.exports = function (grunt) {
    grunt.initConfig({
        concurrent: {
            dev: [
                'watch'
            ],
            options: {
                logConcurrentOutput: true
            }
        },
        jshint: {
            server: [
                '**/*.js',
                '!node_modules/**/*.js'
            ],
            options: {
                node: true
            }
        },
        watch: {
            all: [
                '**/*/.js',
                '!node_modules/**/*.js'
            ],
            tasks: [
                'jshint'
            ]
        }
    });

    grunt.loadNpmTasks('grunt-concurrent');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', [
        'concurrent:dev'/*,
        'jshint',
        'watch'*/
    ]);
};

    grunt.loadNpmTasks('grunt-concurrent');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

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

N.B. I've not added grunt-nodemon into the mix yet.

It looks like concurrent is running watch but when I modify a file it appears jshint isn't running. I certainly don't get any output in the Terminal (I thought logConcurrentOutput: true does this).

Here is the output I get in the Terminal:

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


Done, without errors.

I would also like to run jshint when I first run the default task (as well as when I modify files).

Can anyone shed some light on where I am going wrong?

Thanks!


Source: (StackOverflow)