[英]How do I run grunt from a different folder than my root project
Is there a way to tell grunt which grunt.js file to use? 有没有办法告诉grunt使用哪个grunt.js文件?
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
我有一个
f:\\a\\b\\tools
文件夹,其中包含grunt.cmd, node.exe,...
,我的实际Web应用程序与GruntFile.js
和所有本地node_modules
在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. 从
a\\c\\my_app
运行grunt工作正常,但试图从其他文件夹运行grunt说一个似乎不起作用。 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.
grunt-cli:grunt命令行界面。 (v0.1.6)
(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.
如果您看到此消息,则表示未找到Gruntfile或者您的项目未在本地安装grunt。 For more information about installing and configuring grunt, please see the Getting Started guide:
有关安装和配置grunt的更多信息,请参阅“入门指南”:
http://gruntjs.com/getting-started http://gruntjs.com/getting-started
You can set two parameters --base
and --gruntfile
您可以设置两个参数
--base
和--gruntfile
From grunt --help
: 来自
grunt --help
:
--base
Specify an alternate base path. --base
指定备用基本路径。 By default, all file paths are relative to the Gruntfile. 默认情况下,所有文件路径都相对于Gruntfile。 (grunt.file.setBase) *
(grunt.file.setBase)*
--gruntfile
Specify an alternate Gruntfile. --gruntfile
指定备用Gruntfile。 By default, grunt looks in the current or parent directories for the nearest Gruntfile.js or Gruntfile.coffee file. 默认情况下,grunt在当前或父目录中查找最近的Gruntfile.js或Gruntfile.coffee文件。
So, you can execute: 所以,你可以执行:
grunt --base c\my_app --gruntfile c\my_app\GruntFile.js mytask
Since grunt 1.3 you can omit --gruntfile
. 从grunt 1.3开始,你可以省略
--gruntfile
。
So, instead of 所以,而不是
grunt --base c\\my_app --gruntfile c\\my_app\\GruntFile.js mytask
you can just 你可以
grunt --base c\\my_app mytask
(and --base
can be replaced with -b
) grunt --base c\\my_app mytask
(和--base
可以替换为-b
)
I'll advise you to run it from your app directory because the modules are installed into nodes_modules, etc. you must move to your app directory and run grunt: 我建议你从app目录运行它,因为模块安装在nodes_modules等中。你必须移动到你的app目录并运行grunt:
cd f:
cd a\c\my_app
grunt {yourTasks}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.