Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run gulp if gulp is installed(node_modules) in different folder than gulpfile.js

Tags:

node.js

npm

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'

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.

like image 327
sidb Avatar asked Aug 27 '15 22:08

sidb


2 Answers

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.

Here's an example:

 <NODE_MODULES DIR>/gulp/bin/gulp.js --gulpfile <GULP FILE> --cwd <SOME DIR>
like image 130
idancali Avatar answered Sep 17 '22 16:09

idancali


There is no need to install gulp globally. First install gulp (ideally on dev dependencies)

npm install gulp --save-dev

Then in the package.json add the line you want to run

"scripts" : { "gulp" : "gulp"} }

Finally in the command line use

npm run gulp

npm will use the binary from the node modules without any need to install it globally or to write down the whole path

like image 31
Gabriel Furstenheim Avatar answered Sep 20 '22 16:09

Gabriel Furstenheim