有没有办法告诉 grunt 使用哪个 grunt.js 文件?
我有一个 f:\a\b\tools
文件夹,其中包含 grunt.cmd, node.exe,...
,
我使用 GruntFile.js
和所有本地 node_modules
的实际 Web 应用程序位于 f:\a\c\my_app
从 a\c\my_app
运行 grunt 工作正常,但尝试从其他文件夹运行 grunt 说 a 似乎不起作用。我是 grunt 的新手,可能我遗漏了一些明显的东西。
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:
最佳答案
可以设置两个参数--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
关于node.js - 如何从与根项目不同的文件夹运行 grunt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14873356/