javascript - Npm 不创建 Gruntfile.js

标签 javascript node.js gruntjs

当第一次尝试安装 Grunt 并遵循许多指南时,我似乎没有在我的项目中获得 Gruntfile.js。你知道我可能做错了什么吗?

macbookpro:Noemptytags $ sudo npm install grunt --save-dev
npm WARN package.json Noemptytags@0.0.0 No repository field.
npm WARN package.json Noemptytags@0.0.0 No README data
grunt@0.4.5 node_modules/grunt
├── dateformat@1.0.2-1.2.3
├── which@1.0.5
├── eventemitter2@0.4.14
├── getobject@0.1.0
├── rimraf@2.2.8
├── colors@0.6.2
├── async@0.1.22
├── hooker@0.2.3
├── grunt-legacy-util@0.2.0
├── exit@0.1.2
├── nopt@1.0.10 (abbrev@1.0.5)
├── lodash@0.9.2
├── minimatch@0.2.14 (sigmund@1.0.0, lru-cache@2.5.0)
├── glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3)
├── coffee-script@1.3.3
├── underscore.string@2.2.1
├── iconv-lite@0.2.11
├── findup-sync@0.1.3 (glob@3.2.11, lodash@2.4.1)
├── js-yaml@2.0.5 (esprima@1.0.4, argparse@0.1.15)
└── grunt-legacy-log@0.1.1 (underscore.string@2.3.3, lodash@2.4.1)

它已经创建了node_modules文件夹,但没有Gruntfile.js

任何见解将不胜感激!

最佳答案

grunt 模块只是您任务的运行器插件。您需要手动创建 gruntfile。

如果您希望生成它,有 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

    $ grunt-init gruntfile

如果您在项目中使用项目脚手架工具,您可以节省大量时间。有grunt-init -jquery 插件、gruntplugins 的生成器。或者更好的是,使用 yeoman 。它会生成您的项目结构以及一个有用的 gruntfile!

关于javascript - Npm 不创建 Gruntfile.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25701623/

相关文章:

javascript - Grunt 监视任务而不是文件?

javascript - 如何检查项目是否已存在于状态中?

javascript - 将整个字符串中的大写字母替换为小写字母和连字符

javascript - 使用HTML5 Canvas 拖放不规则图像

node.js - Node - Mongodb - 如何查询特定的嵌套字段

javascript - 使用 ElasticSearch 在变量定义的字段上搜索

node.js - Socket.IO 在 IE 中使用 XHR 轮询

javascript - 未捕获的类型错误 : Cannot read property 'hasOwnProperty' of undefined

javascript - 用 browserify 填充一个 jQuery 插件

javascript - grunt-contrib-jasmine ReferenceError : Can't find variable: jQuery