当第一次尝试安装 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 个选项:
安装grunt-init全局:
$ npm install grunt-init -g
-
$ git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile
在目录中运行 grunt init
$ grunt-init gruntfile
瞧
如果您在项目中使用项目脚手架工具,您可以节省大量时间。有grunt-init -jquery 插件、gruntplugins 的生成器。或者更好的是,使用 yeoman 。它会生成您的项目结构以及一个有用的 gruntfile!
关于javascript - Npm 不创建 Gruntfile.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25701623/