发出咕声,并显示“无法找到本地咕gr声". [英] Grunt concat failing with "Unable to find local grunt"
问题描述
我已经像这样安装了Grunt,所以`npm install -g grunt-cli成功了.
I have installed Grunt like so `npm install -g grunt-cli successfully.
我还成功安装了grunt-contrib-concat库,如下所示:npm install grunt-contrib-concat --save-dev
I have also installed the grunt-contrib-concat libary succesfully like so: npm install grunt-contrib-concat --save-dev
我创建了package.json
:
{
"name": "my-project-name",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-nodeunit": "~0.1.2"
}
}
和Gruntfile.js
:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/init.js', 'src/Game.js', 'ui/Ui.js', 'ui/AddBTS.js', 'ui/Toolbar.js'],
dest: 'built.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
};
现在,当我运行grunt concat
时,出现以下错误:
Now when I run grunt concat
I get the following error:
致命错误:无法找到本地咕unt声. 如果您看到此消息,则说明找不到Gruntfile或gruntfile 尚未在您的项目本地安装.有关更多信息 安装和配置grunt,请参阅《入门指南》:
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:
这是我第一次使用Grunt,现在已经尝试解决这个问题2个多小时.请有人帮助我,并告诉我我没有正确设置的内容.
This is my first time using Grunt and I've been trying to solve this problem for over 2 hours now. Please could someone help me and advise what I've not set up correctly.
提前谢谢!
推荐答案
很有可能在您的项目文件夹中未本地安装Grunt(这与grunt-cli不同).您将其保存在package.json中,因此请尝试执行npm install
或npm install grunt
替代.
It's likely that Grunt is not installed locally in your project folder (which is different than grunt-cli). You have it in your package.json so try doing npm install
or alternately npm install grunt
.
有关更多信息,请参见入门页面:
For more information see the getting started page:
请注意,安装
grunt-cli
不会安装grunt任务运行程序! grunt CLI的工作很简单:运行Gruntfile
旁边已安装的grunt版本.这样一来,即可在同一台计算机上同时安装多个版本的grunt.
Note that installing
grunt-cli
does not install the grunt task runner! The job of the grunt CLI is simple: run the version of grunt which has been installed next to aGruntfile
. This allows multiple versions of grunt to be installed on the same machine simultaneously.
这篇关于发出咕声,并显示“无法找到本地咕gr声".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!