2014-09-06 47 views
0

第一次尝试安装Grunt时,并遵循很多指南,我似乎没有在我的项目中获得Gruntfile.js。任何想法我可能做错了什么?Npm没有创建Gruntfile.js

macbookpro:Noemptytags $ sudo npm install grunt --save-dev 
npm WARN package.json [email protected] No repository field. 
npm WARN package.json [email protected] No README data 
[email protected] node_modules/grunt 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected]) 
├── [email protected] 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected], [email protected]) 
├── [email protected] ([email protected], [email protected]) 
└── [email protected] ([email protected], [email protected]) 

它创造node_modules文件夹,但没有Gruntfile.js

任何有识之士将不胜感激!

回答

2

grunt模块只是您的任务的插件插件。你需要手动创建你的grunt文件。

有1种选择,如果你希望它产生:

  1. 安装grunt-init全球:

    $ npm install grunt-init -g

  2. 克隆grunt-init-gruntfile-repo

    $ git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile

  3. 在目录

    $ grunt-init gruntfile

运行咕噜初始化瞧

,你可以节省大量的时间,如果你想使用项目的脚手架工具为您的项目。有grunt-init-用于jquery-plugins,gruntplugins的生成器。甚至更好,请使用yeoman。生成你的项目结构加上一个有用的gruntfile!

+0

感谢您的信息。 – 2014-09-06 15:43:20

+0

我真的很讨厌使用命令行,现在看来我必须一直这样做。我不知道为什么'开始'安装假设你知道每一步的方式。我宁愿命令的列表,像 - NPM安装-g咕噜-CLI - 去项目 - NPM初始化 - NPM安装 - NPM安装咕噜--save-dev的 - NPM安装咕噜-INIT -g - clone $ git clone https://github.com/gruntjs/grunt-init-gruntfile.git〜/ .grunt-init/gruntfile - grunt-init gruntfile – 2014-09-06 16:08:25

+0

如果你讨厌使用命令行,为什么选择grunt ???使用grunt-init只是一个让你更容易的选择。如果您不喜欢它,请继续在您选择的编辑器中自行创建grunt文件!不应该难以创建新的JavaScript文件。当涉及到配置任务时,您必须对其进行编辑,并且您可以决定要使用哪些任务...编辑:而且grunt-docs非常适合如何创建新的grunt文件,配置任务等等! – hereandnow78 2014-09-06 18:58:45