Grunt/JSHint installation error

大兔子大兔子 提交于 2019-12-02 16:43:21

问题


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
grunt-cli@0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve@0.3.1
├── nopt@1.0.10 (abbrev@1.0.7)
└── findup-sync@0.1.3 (lodash@2.4.2, glob@3.2.11)

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.

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/31952533/grunt-jshint-installation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!