nicosantangelo / sublime-gulp

Run Gulp tasks and use snippets from Sublime Text
https://sublime-gulp.nicosantangelo.com/
MIT License
155 stars 18 forks source link

Doesn't seem to work in OSX #35

Closed cksachdev closed 9 years ago

cksachdev commented 9 years ago

My Gulp file

'use strict';

var gulp = require('gulp');

require('require-dir')('./gulp');

gulp.task('default', ['clean'], function () {
    gulp.start('build');
});

I can see the package is loaded.

reloading plugin FixMacPath.FixPath
reloading plugin Gulp.base_command
reloading plugin Gulp.cross_platform_codecs
reloading plugin Gulp.gulp
reloading plugin Gulp.progress_notifier

But when I try to run Gulp, I still get the errors

Running 'build'...

module.js:340
    throw err;
          ^
Error: Cannot find module 'gulp-util'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/bin/gulp:4:13)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Is there any way to check and run the commands directly in sublime, to make sure that it has detected the right versions and environment variables needed to run Gulp? I have installed SublimeFixMacPath.

nicosantangelo commented 9 years ago

I think that this has to do with require-dir, I never really tried it and I'm not sure it works correctly.

There's really no way to check if the gulp version you're running from sublime is correct ( I think I'll add something like that later ), but you can force your env vars with exec_args.

I have little time on my hands lately but I'm intending to support require-dir ( #34 ). I need to have a local project to test the package on first.

If you don't mind, how is your gulp project setup?, do you have a gulp folder with every task in it?

cksachdev commented 9 years ago

Yes, there is a gulp directory with all the tasks inside it. Refer to screenshot below: Screenshot

nicosantangelo commented 9 years ago

Hello again!

I'm working on a new command to run an arbitrary commands with gulp, which will allow running -v if necessary. But in the meantime, if you're running Sublime-gulp 4.5.4 you can define a specific keybinding to:

{ "keys": ["KEYS"], "command": "gulp", "args": { "task_name": "", "task_flag": "-v" } }

Still, I can't seem to recreate the error, my local setup:

gulpfile.js

'use strict';

var gulp = require('gulp');

require('require-dir')('./gulp');

gulp.task('default', ['clean'], function() {
  gulp.start('clean');
});

./gulp/clean.js

var gulp = require('gulp'),
    rimraf = require('rimraf');

gulp.task('clean', function() {
  rimraf.sync('www/dist/main.js');
  rimraf.sync('www/dist/main.min.js');
});

Preferences -> Package Settings -> Gulp -> Settings - User (this might not be necessary or different for your environment)

{
    "exec_args": {
        "path": "/bin:/usr/bin:/usr/local/bin"
    }
}

After picking Gulp on Sublime, I can see clean and default. After picking `clean:

Running 'clean'...
[12:53:39] Using gulpfile ~/path/gulpfile.js
[12:53:39] Starting 'clean'...
[12:53:39] Finished 'clean' after 966 μs

So! Things you could try:

  1. Try adding exec_args to your settings
  2. Disable SublimeFixMacPath and re-try with and without exec_args

If that does not work, please let me know what is inside your build.js task and your gulp version.

Let me know and thanks!

nicosantangelo commented 9 years ago

This should be working as of Version 5 (v5.0.0). If you have any issues, please let me know ( @ mention me and I'll reopen this issue ).