Grunt/JSHint installation error

317 views Asked by At

Im new to development and im using Steven Foote's book "learning to program" im currently trying to finish a portion of the project that requires you to install Node.js and Grunt. I seem to be having a problem with installing grunt.. hope the following makes sense.

i Installed Node.js

now im moving towards installing NPM, but first i navigate to the directory:

/Users/MR/Desktop/kittenbook

then i execute the command npm

the command seems to execute correctly, based off the books output results. the next command i entered is, and receive the following error:

Mannys-MacBook-Pro:kittenbook mannyr$ ~/Desktop/kittenbook/ sudo npm install -g grunt-cli
-bash: /Users/MR/Desktop/kittenbook/: is a directory

so instead i'ved tried:

Mannys-MacBook-Pro:kittenbook mannyr$ sudo npm install -g grunt-cli

i receive the following output:

/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
[email protected] /usr/local/lib/node_modules/grunt-cli
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])

here are my files:

GruntFile.js

module.exports = function(grunt){
    // project configuration
    grunt.initConfig({

        concat:{
            release: {
                src: ['js/values.js', 'js/prompt.js'],
                dest:'release/main.js'
            }
        },
        copy: {
            release: {
                src: 'manifest.json',
                dest: 'release/manifest.json'
            }
        },
        jshint: {
            files: ['js/values.js', 'js/prompt.js']
        }
    });
    // we will load grunt plugins here
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    // we will register tasks here
    grunt.registerTask('default', ['jshint', 'concat', 'copy']);

};


package.json

{
    "name": "kittenbook",
    "version": "0.0.1",
    "devDependencies":{
        "grunt":"~0.4.2",
        "grunt-contrib-concat": "~0.3.0",
        "grunt-contrib-jshint": "~0.6.3",
        "grunt-contrib-copy": "~0.5.0"
    }

}

when i try running the following command i receive this issue:

Mannys-MacBook-Pro:kittenbook mannyr$ grunt jshint
Warning: Task "jshint" not found. Use --force to continue.

Aborted due to warnings.
2

There are 2 answers

1
Ahmad Alfy On

According to the information you are giving, you only installed:

  • Node
  • NPM
  • Grunt Client

The error message you are getting is because the dependencies in your package.json are not installed:

    "grunt":"~0.4.2",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-jshint": "~0.6.3",
    "grunt-contrib-copy": "~0.5.0"

Go to the directory where package.json exist and run npm install. It will install these packages and then try grunt jshint. It is supposed to work.

0
world34 On

issue was the file name GruntFile.js, should have been Gruntfile.js