【发布时间】:2016-01-12 07:13:49
【问题描述】:
我使用 Grunt 作为“JS Task Runner”。
节点安装在“C:/Program Files”中。
NPM 安装在 C:/users/Peterson/appdata/roaming/npm 中。
npm 文件夹中的 Grunt、Bower 和 Grunt-cli。
创建一个项目 - D:/Project 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> 咕噜声
Fatal Error: Unable to find local grunt
有人可以帮忙吗?
【问题讨论】:
-
您是否在
D:/Project A文件夹中运行了npm install? -
不,我没有。我在安装 node js 时运行它,所以它安装在 C:/users/Peterson/appdata/roaming/npm
-
我需要在 'D:/projectA' 目录中再次运行 npm 吗?如果是,为什么?
标签: javascript json node.js gruntjs npm