我正在使用grunt作为“JS Task Runner”。
节点安装在“C:/ Program Files”中。
NPM安装在C:/ users/Peterson/appdata/roaming/npm中。
npm文件夹内的Grunt,Bower和Grunt-cli。使用grunt进行自定义项目
创建项目 - d:/项目A.
内d以下文件:/项目A - “的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:/项目A>咕噜
Fatal Error: Unable to find local grunt
有人能帮忙吗?
指定的是否在'D:/ Project A'文件夹中运行'npm install'? – topheman
不,我没有。我在安装节点js时运行它,所以它安装在C:/ users/Peterson/appdata/roaming/npm – Deadpool
我需要在'D:/ projectA'目录中再次运行npm吗?如果是这样,为什么? – Deadpool