grunt-contrib-watch icon indicating copy to clipboard operation
grunt-contrib-watch copied to clipboard

Cannot find gruntfile if watch is originally run from a different directory.

Open Axiverse opened this issue 9 years ago • 4 comments

I have a project that has a npm script that runs from the root directory. The gruntfile.js is in a utils subdirectory.

the command in package.json is "watch": "grunt --gruntfile utils/gruntfile.js watch" and this runs fine. However when a file is changed, it runs grunt with the same parameters but from the utils folder so it looks for utils/utils/gruntfile.js which doesn't exist and throws the following error.

Reading "gruntfile.js" Gruntfile...ERROR
Fatal error: Unable to find "/git/Orb/utils/utils/gruntfile.js" Gruntfile.

For clarity, package.json is in /git/Orb/package.json and the gruntfile.js is in /git/Orb/utils/gruntfile.js

Axiverse avatar Apr 25 '15 05:04 Axiverse

I have the same issue

Rebzie avatar Aug 05 '15 07:08 Rebzie

I'm having this issue as well, and it has blocked my development. I'm far from an expert in JavaScript, but I'm going to look into this now, and report back if I can come up with a patch that works for me.

Microserf avatar Dec 07 '15 15:12 Microserf

I believe I've found the problem. I created and submitted a PR to address this, though I'd be grateful if someone could review my code and let me know if I've missed any best practices -- this is my first JavaScript code commit!

In the meantime, there exists a workaround, which is to pass an absolute path to the --gruntfile option.

Microserf avatar Dec 07 '15 18:12 Microserf

I'm facing the same issue, path is duplicated when watch triggers grunt.

ctrl-f5 avatar Dec 10 '15 19:12 ctrl-f5