-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: gulp is not defined (running at Windows) #12
Comments
Hello! I had this problem on Windows and usually one of the following fixes it:
Let me know how it goes! |
Gulp is installed globally as well as locally. So that doesn't seem to be the problem. Any idea what to add specifically to the "path"? My Windows environment path setting seems to be alright, and overriding them trough the config doesn't seem to help. I've tried the following paths in the exec_args.path property, but they don't fix the "gulp is not defined" error.
|
The paths seems to be allright too...let's see. That error is thrown by the So what it does is: var requireGulp = function(gulpfilePath) {
// Read your gulpfile.js
var fileSrc = fs.readFileSync(gulpfilePath);
// add the exports at the end so it can be required by node
fileSrc += ";module.exports = gulp;";
// write the temporal file
fs.writeFileSync(tmpfilePath, fileSrc);
try {
// require the new 'gulpfile', with module.exports = gulp; at the end
return require(tmpfilePath);
} catch(ex) {
// On error, delete the tmp file and throw (the one that gets printed to the log)
fs.unlink(tmpfilePath);
throw ex;
}
}; So!, if you don't mind, try adding
When I do it, it logs the (sorry for the inconvenience) |
Briljant! I've just fixed it. Well, you did actually. The problem was my way of setting up gulp. My gulpfile.js never required gulp itself. This works, because I separate my tasks into individual js files. My gulpfile.js looks like this: var fs = require('fs');
var path = require('path');
var jsfiles = function(name) {
return /(\.(js|coffee)$)/i.test(path.extname(name));
}
var tasks = fs.readdirSync('./gulp-tasks/').filter(jsfiles);
tasks.forEach(function(task) {
require('./gulp-tasks/' + task);
}); Appending a require to the file, fixed the problem. Export isn't required. // require(d) gulp for compatibility with sublime-gulp.
var gulp = require('gulp'); |
Wow I never thought of that, it's a good idea. I think I'll add an explanation to the README that covers this case (and I think I'll start using something similar :P), thanks a lot for letting me know what it was! |
Without this, I get the follow error: ``` C:\Users\zoiah\Documents\dev\gulpfile.js:4 gulp.task('screeps', function() { ^ ReferenceError: gulp is not defined ``` Found the fix on nicosantangelo/sublime-gulp#12
I just can't get it working on Windows. Gulp runs fine from command, but sublime-gulp is throwing the error below to it's log. Any idea how to get this working?
The text was updated successfully, but these errors were encountered: