如何从不同于我的根项目的文件夹运行grunt [英] How do I run grunt from a different folder than my root project

查看:101
本文介绍了如何从不同于我的根项目的文件夹运行grunt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉grunt使用哪个grunt.js文件?

我有一个 f:\ a\b \tools 包含 grunt.cmd,node.exe,...
的文件夹 GruntFile.js 和所有本地 node_modules 位于 f:\ a\c\my_app



a \c\my_app 运行grunt可以正常工作,但尝试从一些其他文件夹运行grunt说,似乎并没有工作。

  f:\a> grunt --config c\\ \\ GruntFile.js 




grunt-cli:grunt命令行界面。 (v0.1.6)



致命错误:无法找到本地咕噜声。

如果您看到消息,Gruntfile未找到,或者grunt尚未在本地安装到您的项目中。有关安装和配置grunt的更多信息,请参阅入门指南:


http://gruntjs.com/getting-started

解决方案

您可以设置两个参数 - base - gruntfile



grunt --help



- base 指定备用基本路径。默认情况下,所有文件路径都与Gruntfile相关。 (grunt.file.setBase)*



- gruntfile 指定一个备用Gruntfile。默认情况下,grunt会在最近的Gruntfile.js或Gruntfile.coffee文件的当前或父目录中查找。



因此,您可以执行:

  grunt --base c\my_app --gruntfile c\my_app\GruntFile.js mytask 


Is there a way to tell grunt which grunt.js file to use?

I have an f:\a\b\tools folder that contains grunt.cmd, node.exe,..., my actual web app with GruntFile.js and all the local node_modules is in f:\a\c\my_app

Running grunt from a\c\my_app works fine but trying to run grunt from some other folder say a does not seem to work. I am new to grunt and may be I am missing something obvious.

f:\a>grunt --config c\GruntFile.js

grunt-cli: The grunt command line interface. (v0.1.6)

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:

http://gruntjs.com/getting-started

解决方案

You can set two parameters --base and --gruntfile

From grunt --help:

--base Specify an alternate base path. By default, all file paths are relative to the Gruntfile. (grunt.file.setBase) *

--gruntfile Specify an alternate Gruntfile. By default, grunt looks in the current or parent directories for the nearest Gruntfile.js or Gruntfile.coffee file.

So, you can execute:

grunt --base c\my_app --gruntfile c\my_app\GruntFile.js mytask

这篇关于如何从不同于我的根项目的文件夹运行grunt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆