运行grunt只是打开一个记事本文件,而不是实际运行任务
Running grunt just opens up a Notepad file instead of actually running the tasks
我正在尝试创建一个基本的Grunt文件来执行一些任务。
问题是,当我从项目目录中执行grunt
时,会打开一个记事本文件,显示grunt.js
的内容,而不是实际运行。
我也试过命名文件Gruntfile.js
,但后来我得到一个消息
grunt-cli: The grunt command line interface. (v0.1.13)
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-cli
。
grunt.js
和Gruntfile.js
看起来都像:
module.exports = function(grunt) {
grunt.initConfig({
});
grunt.registerTask('foo', 'A sample task that logs stuff.', function(arg1, arg2) {
if (arguments.length === 0) {
grunt.log.writeln(this.name + ", no args");
} else {
grunt.log.writeln(this.name + ", " + arg1 + " " + arg2);
}
});
grunt.registerTask('default', []);
};
问题是我缺少一个package.json
文件。我只是从来没有创建过。
我通过运行
解决了这个问题npm init
生成
即使grunt是全局安装的,您也需要将其添加到您的项目中-在您的项目目录中运行:
npm install grunt --save-dev
不要重命名你的任务文件(保留Gruntfile.js
),然后运行grunt
应该工作良好
相关文章:
- 使用压缩的JavaScript文件(不是运行时压缩)
- Javascript运行php文件,然后下载文件
- 从Chrome扩展名中的popup.html文件在background.js文件中运行一个函数
- 如何从“”运行url;.js”;文件
- 如何使用Gmail运行.js文件
- 如何运行从TFS获取项目的windows脚本文件
- 在Node Webkit应用程序中从DOM单击按钮时运行批处理文件
- 是否可以从javascript文件中将量角器作为模块运行
- Meteor发布/订阅无法从服务器文件夹中运行
- 如何显示由ajax调用运行的PHP文件的echo
- 通过Wordpress中的jquery调用运行php文件
- 从JavaScript文件运行Firebug Lite
- 如何在Grunt.js中观察多个文件,但只在更改的文件上运行任务
- 如何在 node.js 中创建和运行文件
- 如何在使用 nsIProcess 运行文件时隐藏命令提示符窗口.bat
- 文件下载完成后运行文件
- 打开程序但不运行文件的HTA页面
- React-只运行文件一旦外部js文件加载(gapi未定义)
- 从终端运行文件代码(启动本地网站)
- 运行文件.未附加的HTML元素的getElementById