Suddenly grunt build fails

builddependenciesgrunt-contrib-uglifygruntjsnpm

I was used to grunt build task to complete successfully, but since I merged my project edits with some of another developer colleague, it suddenly fails with an error I've never seen before:

grunt build
Loading "imagemin.js" tasks...ERROR
>> Error: Cannot find module 'process-nextick-args'
Loading "cdnify.js" tasks...ERROR
>> Error: Cannot find module 'abbrev'
Loading "grunt-karma.js" tasks...ERROR
>> Error: Cannot find module 'uglify-js'

Running "clean:dist" (clean) task
>> 0 paths cleaned.

Running "wiredep:app" (wiredep) task
Warning: Cannot find module './lang/clone' Use --force to continue.

Aborted due to warnings.


Execution Time (2015-09-25 09:44:30 UTC)
wiredep:app  31ms
Total 31ms

In the Gruntfile.js I commented imagemin and cdnify out in concurrent:dist and build tasks.

What have I done wrong?

Here there are some informations about the version of the stuff I'm using:

node -v && npm -v && grunt --version
v0.10.35
2.1.1
grunt-cli v0.1.13
grunt v0.4.5

Moreover, I tried to run an npm install before the grunt build, but I have these warnings I've never seen before, except the very three ones:

npm WARN package.json rwui@0.0.0 No description
npm WARN package.json rwui@0.0.0 No repository field.
npm WARN package.json rwui@0.0.0 No README data
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\vinyl-fs\node_modules\glob-watcher\node_modules\gaze\node_modules\globule\node_modules\glob requires graceful-fs@'~1.2.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\vinyl-fs\node_modules\graceful-fs,
npm WARN unmet dependency which is version 3.0.8
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle\node_modules\bin-build\node_modules\download\node_modules\gulp-decompress\node_modules\gulp-util requires object-assign@'^3.0.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle\node_modules\bin-build\node_modules\download\node_modules\object-assign,
npm WARN unmet dependency which is version 4.0.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle\node_modules\bin-wrapper\node_modules\download\node_modules\gulp-decompress\node_modules\gulp-util requires object-assign@'^3.0.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle\node_modules\bin-wrapper\node_modules\download\node_modules\object-assign,
npm WARN unmet dependency which is version 4.0.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\bin-build\node_modules\download\node_modules\gulp-decompress\node_modules\gulp-util requires object-assign@'^3.0.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\bin-build\node_modules\download\node_modules\object-assign,
npm WARN unmet dependency which is version 4.0.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\bin-wrapper\node_modules\download\node_modules\gulp-decompress\node_modules\gulp-util requires object-assign@'^3.0.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\bin-wrapper\node_modules\download\node_modules\object-assign,
npm WARN unmet dependency which is version 4.0.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin\node_modules\bin-build\node_modules\download\node_modules\gulp-decompress\node_modules\gulp-util requires object-assign@'^3.0.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin\node_modules\bin-build\node_modules\download\node_modules\object-assign,
npm WARN unmet dependency which is version 4.0.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin\node_modules\bin-wrapper\node_modules\download\node_modules\gulp-decompress\node_modules\gulp-util requires object-assign@'^3.0.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-contrib-imagemin\node_modules\imagemin\node_modules\imagemin-optipng\node_modules\optipng-bin\node_modules\bin-wrapper\node_modules\download\node_modules\object-assign,
npm WARN unmet dependency which is version 4.0.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-google-cdn\node_modules\bower\node_modules\inquirer\node_modules\chalk\node_modules\has-ansi requires ansi-regex@'^0.2.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-google-cdn\node_modules\bower\node_modules\inquirer\node_modules\ansi-regex,
npm WARN unmet dependency which is version 1.1.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-google-cdn\node_modules\bower\node_modules\inquirer\node_modules\chalk\node_modules\strip-ansi requires ansi-regex@'^0.2.1' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-google-cdn\node_modules\bower\node_modules\inquirer\node_modules\ansi-regex,
npm WARN unmet dependency which is version 1.1.1
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-google-cdn\node_modules\google-cdn\node_modules\bower requires chalk@'0.5.0' but will load
npm WARN unmet dependency C:\Users\gesposito\Documents\Developer\Software\Production\reportmed\api_ui\node_modules\grunt-google-cdn\node_modules\chalk,
npm WARN unmet dependency which is version 0.5.1

EDIT

I leave here the relevant parts of my package.json:

  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-autoprefixer": "^2.1.0",
    "grunt-concurrent": "^1.0.0",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-compass": "^1.0.1",
    "grunt-contrib-concat": "^0.5.0",
    "grunt-contrib-connect": "^0.9.0",
    "grunt-contrib-copy": "^0.7.0",
    "grunt-contrib-cssmin": "^0.11.0",
    "grunt-contrib-htmlmin": "^0.3.0",
    "grunt-contrib-imagemin": "^0.9.2",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-contrib-uglify": "^0.7.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-filerev": "^2.1.2",
    "grunt-google-cdn": "^0.4.3",
    "grunt-karma": "^0.10.1",
    "grunt-newer": "^1.1.0",
    "grunt-ng-annotate": "^0.8.0",
    "grunt-svgmin": "^2.0.0",
    "grunt-usemin": "^3.0.0",
    "grunt-wiredep": "^2.0.0",
    "jasmine-core": "^2.2.0",
    "jshint-stylish": "^1.0.0",
    "karma": "^0.12.31",
    "karma-chrome-launcher": "^0.1.8",
    "karma-jasmine": "^0.3.5",
    "karma-phantomjs-launcher": "^0.1.4",
    "load-grunt-tasks": "^2.0.0",
    "time-grunt": "^1.0.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test"
  }

EDIT

Keep in mind that my colleague's package.json doesn't show any difference from mine.

Best Solution

Looks like you have outdated/mixed npm modules - did you merge your node_modules folder with your colleagues?

Anyway, I suggest deleting your local node_modules directory then re-running npm install.

Once you're stable again, the proper workflow should be:

  • node_modules should be out of source control
  • when you first get the project, run npm install to setup your local node_modules
  • then you only need to touch it when package.json changes
  • in that case, you run npm update to install the new versions locally
Related Question