如果在gulpfile.js以外的其他文件夹中安装gulp(node_modules),如何运行gulp [英] How do you run gulp if gulp is installed(node_modules) in different folder than gulpfile.js

查看:186
本文介绍了如果在gulpfile.js以外的其他文件夹中安装gulp(node_modules),如何运行gulp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个目录中有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 参数传入你的gulp文件的位置。另外,如果你想控制你的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.

下面是一个例子: p>

Here's an example:

 <NODE_MODULES DIR>/gulp/bin/gulp.js --gulpfile <GULP FILE> --cwd <SOME DIR>

这篇关于如果在gulpfile.js以外的其他文件夹中安装gulp(node_modules),如何运行gulp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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