使用grunt进行自定义项目

我正在使用Grunt作为“JS Task Runner”。
节点安装在“C:/ Program Files”中。
NPM安装在C:/ users / Peterson / appdata / roaming / npm中。
grunt,bower和grunt-cli在npm文件夹里。

创build一个项目 – D:/项目A.
D:/ ProjectA – “package.json”gruntfile.js文件

的package.json

{ "name": "Test-Project", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-concat": "~0.1.3" } } 

gruntfile.js

 module.exports = function(grunt) { // Project configuration. grunt.initConfig({ //Read the package.json (optional) pkg: grunt.file.readJSON('package.json'), // Metadata. meta: { basePath: '../', srcPath: '../src/', deployPath: '../deploy/' }, banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + '* Copyright (c) <%= grunt.template.today("yyyy") %> ', // Task configuration. concat: { options: { stripBanners: true }, dist: { src: ['<%= meta.srcPath %>scripts/fileone.js', '<%= meta.srcPath %>scripts/filetwo.js'], dest: '<%= meta.deployPath %>scripts/app.js' } } }); // These plugins provide necessary tasks. grunt.loadNpmTasks('grunt-contrib-concat'); // Default task grunt.registerTask('default', ['concat']); }; 

在CLI D:/ ProjectA> grunt中

 Fatal Error: Unable to find local grunt 

有人可以帮忙吗?

你已经安装了node / npm和Grunt&Bower的clis(通过npm install -g全局安装它们)

你所缺less的是在你的项目的根目录(你的package.json文件所在的位置)运行npm install来安装你在package.json指定的项目依赖