question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gulpfile.babel.js not used if parent directory has a gulpfile.js

See original GitHub issue

What were you expecting to happen?

for directory structure like

project-dir/
    submodules/
       my-module/
           gulpfile.babel.js
    gulpfile.js

when i run gulp in the project-dir/submodules/my-module directory i expected it to use project-dir/submodules/my-module/gulpfile.babel.js.

What actually happened?

it uses project_dir/gulpfile.js.

if i change the name of project-dir/gulpfile.js to project-dir/gulpfile.babel.js it works as expected.

(as the example directory structure suggests, this problem cropped up when changing a submodule in a project to use gulpfile.babel.js while the main repo was still using gulpfile.js)

Please post a sample of your gulpfile (preferably reduced to just the bit that’s not working)

it doesn’t matter what’s in the gulpfile. you can reproduce via:

mkdir project-dir
cd project-dir
npm init -y
npm install --save-dev gulp
touch gulpfile.js
mkdir -p submodules/my-module
cd submodules/my-module
npm init -y
npm install --save-dev gulp babel-register
touch gulpfile.babel.js
gulp -T

output shows gulp walking up the directory tree to gulpfile.js:

[21:49:03] Working directory changed to /private/tmp/project-dir
[21:49:03] Using gulpfile /private/tmp/project-dir/gulpfile.js
[21:49:04] Tasks for /private/tmp/project-dir/gulpfile.js

then if you

mv ../../gulpfile.js ../../gulpfile.babel.js
gulp -T

you’ll see it use the correct file:

[21:50:08] Requiring external module babel-register
[21:50:08] Using gulpfile /private/tmp/project-dir/submodules/my-module/gulpfile.babel.js
[21:50:08] Tasks for /private/tmp/project-dir/submodules/my-module/gulpfile.babel.js

What version of gulp are you using?

$ gulp --version
[21:36:13] Requiring external module babel-register
[21:36:13] CLI version 3.9.1
[21:36:13] Local version 3.9.1

What versions of npm and node are you using?

$ npm --version
3.10.3

$ node --version
v6.6.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
phatedcommented, Oct 12, 2016

This was just fixed in findup-sync@0.4.3 - please upgrade your dependency tree.

1reaction
MGBRcommented, Oct 4, 2016

I’m having the same issue.

Also, if the parent dir doesn’t have a gulpfile, gulp returns an error Local gulp not found in <parent-dir>. In my project, it’s looking for the gulpfile three levels up the file tree from where I’m running gulp

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parent directory's gulpfile forces working directory change ...
Open package.json in your Foundaton For Emails folder and add the --gulpfile gulpfile.babel.js option to all of your npm scripts:
Read more >
JavaScript and Gulpfiles - gulp.js
A gulpfile is a file in your project directory titled gulpfile.js (or capitalized as Gulpfile.js , like Makefile), that automatically loads when you...
Read more >
babel/register - Babel.js
One of the ways you can use Babel is through the require hook. The require hook will bind itself to node's require and...
Read more >
Gulp for WordPress: Initial Setup - CSS-Tricks
So, how can we use Gulp to power the tasks for a WordPress theme? ... we've added on top of the two required...
Read more >
Simplify Front-end JS and CSS Optimization With Gulp - Toptal
The gulpfile.js file is where we will define the tasks that Gulp will perform for us. The package.json is used by npm to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found