"Error: spawn /usr/bin/compass ENOENT" when using gulp-compass - node.js

I'm attempting to run the following Gulp task to compile Sass files, using the plugin, gulp-compass on OS X Yosemite 10.5.5.
var path = require("path");
var gulp = require("gulp");
var compass = require("gulp-compass");
gulp.task("compile2013Base", function() {
var projectPath = path.join(__dirname, '../../ ');
gulp.src(['../sass/desktop/css/2013/*.scss']).pipe(compass({
project: projectPath,
css: 'htdocs/assets/css/2013/',
sass: 'sass/desktop/css/2013'
})).on('error', errorHandler).pipe(gulp.dest('../../htdocs/assets/css/2013/'));
});
function errorHandler (error) {
console.log(error.toString());
this.emit('end');
}
However, when I try to run the task like gulp compile2013Base, I get the following error:
> gulp compile2013Base
[13:39:06] Using gulpfile [**redacted**]/scripts/js/gulpfile.js
[13:39:06] Starting 'compile2013Base'...
[13:39:06] Finished 'compile2013Base' after 9.07 ms
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn /usr/bin/compass ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
I already have compass installed at /usr/bin/compass, and running compass in the terminal does not show any errors.
I'm not sure what to go on here, how do I get the error details?

This is helped me
sudo gem install -n /usr/local/bin compass
see Error: "compass:dist" Fatal error: spawn /usr/bin/compass ENOENT

Related

Impossible to install spookyjs

I want to install spookyjs and find it impossible to do so. I've tried three different ways:
Run the standard spookyjs package.json provided in spookyjs github.
Then I try to run hello.js and I am greeted with this error.
C:\Users\User1\Desktop\test2>node hello.js
events.js:183
throw er; // Unhandled 'error' event
^
Error: spawn casperjs ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
Installed phantomjs and casperjs globally and package.json installed spooky and tiny-jsonrpc. I get the same error message.
Installed these dependencies from package.json
"dependencies": {
"spooky": "^0.2.5",
"tiny-jsonrpc": "^2.0.1",
"phantom": "^4.0.12",
"casperjs": "^1.1.4"
I get the same error.
I came across this link:
Issue
and it detailed the solution. That is this chunk of code:
const
path = require('path'),
_ = require('underscore')
;
var
// close env to pass to spawn
env = _.clone(process.env),
// get the PATH - in my local Windows, it was Path
envPath = env.PATH || env.Path,
// get path to node_modules folder where casperjs and
// phantomjs-prebuilt are installed
// this will be different for you
binDir = path.join(__dirname, './../../node_modules/.bin'),
Spooky = require('spooky')
;
// update the path in the cloned env
env.PATH = env.Path = `${envPath};${binDir}`;
var spooky = new Spooky({
child: {
// spooky is trying to call casperjs.bat for windows
// .bat doesn't work, so call the update .cmd file
// this fixes issue 2 with the file
command: /^win/.test(process.platform) ? 'casperjs.cmd' : 'casperjs',
transport: 'http' ,
spawnOptions: {
// set the env using cloned version
// this fixes issue 1 with the path
env: env
}
},
...
So now the program runs without an error. Actually though it runs without anything, because while on the one hand no error pops up, on the other nothing pops up. I debbuged by putting console.log() inside spooky's callback function but nothing is displayed. That is for another question though...
But the error i was receiving has vanished and the interpreter runs the code.

Converting Pdf pages into images in nodeJS using pdf2img module

I am trying to convert Pdf pages into images using the pdf2img module.My code is as follows..
var pdf2img = require('pdf2img');
var input = __dirname + '/pd.pdf';
pdf2img.setOptions({
type: 'png', // png or jpeg, default png
size: 410, // default 1024
density: 200, // default 600
outputdir: __dirname + '/output' // mandatory, outputdir must be absolute path
});
pdf2img.convert(input, function(info) {
console.log(info);
});
I am getting following error after running above code..
C:\node\app>node conv.js
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn pdfinfo ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
pdf2img is using pdfinfo for the pdf library.
From pdfinfo's homepage:
Requires
Node.js
npm node package manager
xpdf / pdfinfo(1)
So download and install Xpdf on your windows computer, and you will hopefully get rid of the ENOENT error.

How to bundle tests and start karma from watch task

Whenever the appropriate files change I would like to bundle my tests and start karma, showing any failed tests.
I currently have the watch task:
gulp.task('default', ['browserify', 'css','runTests'], function () {
gulp.watch('./src/js/**/*.js', ['browserify']);
gulp.watch('./src/js/**/*.js', ['runTests']);
});
Which starts up the runTests.js
var testFile = [
'./src/components/tests/suite.js'
];
// bundle tests
var cmd = child.spawn('browserify', ['-e', './src/components/tests/suite.js', '-t', 'reactify', '-t']);
cmd.on('close', function (code) {
//cmd finished start karma
gulp.src(testFiles)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
throw err;
});
});
my console currently errors here:
[17:04:27] Starting 'runTests'...
[17:04:27] Finished 'runTests' after 2.73 ms
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn browserify ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
Process finished with exit code 1
I can get a basic command to work child = spawn("ls");
But not the browserify command, can anyone help?
You can use the browserify API within a gulp task. Look at substack/node-browserify#1170 for some tips on globbing with browserify. Then you can just include the output file in your karam config files array.
// Disclaimer: This code is untested
var files = require("glob").sync('./src/js/**/*.js');
files.push('./src/components/tests/suite.js');
var browserify = require("browserify")(files, {transform: 'reactify'});
// your can do more config on the browserify instance
// Run browserify bundle and output to a file
var myFile = require('fs').createWriteStream('myOutput.txt');
browserify.bundle().pipe(myFile);

node errors when running gulp del task

I cannot figure out why I am getting a node ENOENT error, when running a simple task to clean out my vendor files.
My gulp task looks like this
var gulp = require('gulp');
var del = require('del');
module.exports = function(opt){
gulp.task('clean:vendor', function(cb){
return del(['src/vendor/'],cb)
});
}
When I run the command gulp clean:vendor against a file structure that looks like this:
gulpfile.js
src/vendor/js
src/vendor/css
I get this error from node, and I cannot figure out how to catch or fix.
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/Users/aycollin/seed/src/vendor/js/bootstrap.js'

Node.js run a java program?

I have a simple nodejs server up and running. I am running into trouble when I try to spawn a child process. the jar file I am trying to access, is in the same directory as the node script. It takes in a command line argument that I am trying to pass in and it outputs data to the command line, which I am trying to pipe into the var child.
var child = require('child_process').spawn('java -jar done.jar',['argument to pass in']);
child.stdout.on('data', function(data) {
console.log(data.toString());
});
child.stderr.on("data", function (data) {
console.log(data.toString());
});
This produces the following error message:
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn java -jar done.jar ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
Any ideas?
You're executing java. -jar and done.jar are arguments to pass.
var child = require('child_process').spawn(
'java', ['-jar', 'done.jar', 'argument to pass in']
);
You will also need to specify the full path to java, or make sure that java is specified in the OS path.

Resources