如果 gulp 安装在与 gulpfile.js 不同的文件夹中(node_modules),你如何运行 gulp [英] How do you run gulp if gulp is installed(node_modules) in different folder than gulpfile.js
问题描述
我在一个目录中有 gulpfile.js,在另一个目录中有 node_modules.当我运行 gulp 时,我得到了错误 -'在'..(目录)中找不到本地 gulp..尝试运行:npm install gulp'
I have gulpfile.js in one directory and node_modules in another. When I run gulp, i get the error - 'Local gulp not found in '..(the directory).. Try running: npm install gulp'
问题是 - 我无法在 gulpfile.js 的目录中安装 gulp,因此我需要一种方法来告诉 gulp 引用我安装了 gulp 的另一个目录.
The thing is - I cannot install gulp in the directory of gulpfile.js and so I need a way to tell the gulp to refere to the other directory i have gulp installed in.
推荐答案
如果你不想全局安装 gulp,你不需要.你可以做的是运行你的 gulp 可执行文件(从你的 node_modules),然后使用 --gulpfile 参数传入你的 gulpfile 的位置.此外,如果您想控制 gulp 的运行位置,请使用 --cwd 参数.
You don't need to install gulp globally if you don't want to. What you can do is run your gulp executable (from your node_modules) and then pass in the location of your gulpfile using the --gulpfile parameter. Also, if you want to control where your gulp is running, make use of the --cwd parameter.
这是一个例子:
<NODE_MODULES DIR>/gulp/bin/gulp.js --gulpfile <GULP FILE> --cwd <SOME DIR>
这篇关于如果 gulp 安装在与 gulpfile.js 不同的文件夹中(node_modules),你如何运行 gulp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!