运行“grunt”命令时出现“致命错误:无法find本地grunt”
我用下面的命令卸载了grunt。
npm uninstall -g grunt 然后我再次用下面的命令安装了grunt。
 npm install -g grunt-cli 
请访问以下链接: https : //npmjs.org/package/grunt-html
我想使用上面的咕噜插件
但是当我运行grunt命令时,它给了我下面的错误:
 D:\nodeJS\node_modules\grunt-html>grunt grunt-cli: The grunt command line interface. (v0.1.6) Fatal error: Unable to find local grunt. If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. For more information about installing and configuring grunt, please see the Getting Started guide: http://gruntjs.com/getting-started 
	
所有的解释在gruntjs.com很好。
请注意,安装grunt-cli不会安装grunt任务运行器! grunt CLI的工作很简单:运行已经安装在Gruntfile旁边的grunt版本。 这允许多个版本的grunt被同时安装在同一台机器上。
所以在你的项目文件夹中,你将需要安装(最好) 最新的grunt版本 :
 npm install grunt --save-dev 
 选项--save-dev会将grunt作为dev-dependency添加到你的package.json中 。 这使重新安装依赖关系变得容易。 
你必须在你的项目文件夹中安装grunt
- 
创build你的package.json $ npm init
- 
安装grunt这个项目,这将被安装在 node_modules/。 –save-dev会将这个模块添加到你的package.json中的devDependency$ npm install grunt --save-dev
- 
然后创buildgruntfile.js并运行 $ grunt
 我想你必须在你的package.json文件中添加grunt。 看到这个链接 。 
由于我在64位Windows操作系统上安装了32位版本的节点,因此我的Windows咕噜声出现了这个问题。 当我特别安装64位版本时,它开始工作。
我今天在Windows 32位,节点0.10.25,和grunt 0.4.5有同样的问题。
我遵循了dongho的回答 ,只需要几个额外的步骤。 这里是我用来解决错误的步骤:
1)创build你的package.json
 $ npm init 
2)为这个项目安装grunt,这将被安装在node_modules /下。 –save-dev会将这个模块添加到你的package.json中的devDependency
 $ npm install grunt --save-dev 
  3)然后创buildgruntfile.js ,这样的示例代码: 
 module.exports = function(grunt) { grunt.initConfig({ jshint: { files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'], options: { globals: { jQuery: true } } }, watch: { files: ['<%= jshint.files %>'], tasks: ['jshint'] } }); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('default', ['jshint']); }; 
 在这里, src/**/*.js和test/**/*.js应该是您在项目中使用的实际JS文件的path 
  4)运行npm install grunt-contrib-jshint --save-dev 
  5)运行npm install grunt-contrib-watch --save-dev 
  6)运行$ grunt 
  注意:当你需要像concat,uglify等通用包的时候,你需要通过npm install来添加这些模块,就像我们在步骤4和5中安装jshint一样 
如果你是一个存在的项目,也许应该执行npm install。
guntjs入门步骤2。