2

I have a linux symlink to a folder called node_modules in my folder with the grunt file but when I run grunt I get this:

Local Npm module "jshint-stylish" not found. Is it installed?

All my other npm modules work fine,any ideas?

my grunt file:

module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-open');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-closure-compiler');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('jshint-stylish');

permissions:

me@pc:~/dev/root/node_modules$ ls -l
total 96

..
drwxr-xr-x 3 me me 4096 Jun 10 14:57 grunt-shell
drwxr-xr-x 3 me me 4096 Jun 10 15:00 jshint-stylish

..

EDIT_____________________ I'm using it in grunt as a reporter:

  jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
FutuToad
  • 2,750
  • 5
  • 36
  • 63
  • I'm guessing you've already checked but are you sure the `jshint-stylish` module is actually installed? Is it definitely in that `node_modules` directory? Does it have the same permissions as other modules? – James Allardice Jun 10 '14 at 14:25
  • @JamesAllardice yeah has the same perms, see the edit thanks – FutuToad Jun 10 '14 at 14:44
  • 1
    It doesn't look like you're using `jshint-stylish` in the right way... it's not a Grunt plugin. See the [readme](https://github.com/sindresorhus/jshint-stylish). – James Allardice Jun 10 '14 at 15:06
  • @JamesAllardice I'm using it in grunt as a reporter, see edit:) – FutuToad Jun 10 '14 at 15:18
  • 2
    In your original code (it's still there in the question) you have `grunt.loadNpmTasks('jshint-stylish');`. You need to get rid of that. – James Allardice Jun 10 '14 at 15:37

3 Answers3

4

Try installing the module manually.

npm install jshint-stylish

worked for me.

Dustin Williams
  • 3,912
  • 2
  • 16
  • 19
0

The load-grunt-configs owner creynders suggests here that the error
"Local Npm module 'jshint-stylish' not found. Is it installed?"
is apparently caused by the requiring of jshint-stylish in the jshint.js config file.
It can't find the jshint-stylish module since it's in a directory outside the project.

However I was unable to make his suggestion working for me, but I found my own way:

// gruntfile.js
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    config: grunt.file.readJSON('grunt-config.json'),
    jshint_reporter: require('jshint-stylish')
});

// grunt-config.json
{
    "jsHintFiles" : [
        "**/modules/*.js"
    ]
}

// jshint.js
module.exports = function(grunt) {
    "use strict";

    grunt.config.merge({"jshint": {
        "default": {
            options: {
                reporter: "<%= jshint_reporter %>"
            },
            src: ["<%= config.jsHintFiles %>"]
        }
    }});
};
Luca Borrione
  • 16,324
  • 8
  • 52
  • 66
0

Check that your NODE_PATH environment variable references your node_modules directory.
Locally it will be:

export NODE_PATH=./node_modules

user5269602
  • 126
  • 6