2

I'm running nodejs (v0.10.25) on Ubuntu 14.04. I've installed jasmine-node globally using npm as per the instructions here : http://help.exercism.io/getting-started-with-javascript.html.
My source file is bob.js and my spec file is called bob_test.spec.js.

When I try to run jasmine-node from the command line using:
~$jasmine-node bob_test.spec.js
I get no errors/output/anything from the program. I just get the command line prompt back.

Running which jasmine-node points me to a script located at /usr/local/bin/jasmine-node which contains the following:

#!/usr/bin/env node

if( !process.env.NODE_ENV ) process.env.NODE_ENV = 'test';

var path = require('path');
require(path.join(__dirname,'../lib/jasmine-node/cli.js'));  

My $PATH includes /usr/local/bin:

I have tried:

  • uninstalling/reinstalling jasmine-node packages
  • uninstalling and reinstalling node/nodejs
  • variations on the arguments to jasmine-node such as :
    • jasmine-node .
    • jasmine-node bob.js

Am I missing something in terms of configuration, or something else entirely?

user259743
  • 33
  • 8
  • Sometimes this has to do with the PATH context for your environment. Can you verify the `jasmine-node` executable you are running (via `which jasmine-node`)? Also look inside the jasmine-node script to see what it contains. If I run on an empty file, I at least see an output that says nothing failed. Does this happen when you run jasmine-node on anything else? – dylants Oct 29 '14 at 02:13
  • @dylants No output whatsoever with any files. I've updated question with info about the $PATH and the script for jasmine-node. – user259743 Oct 29 '14 at 02:23
  • If you just run `jasmine-node` does it show the usage output on the console? If you were to create a file (called file.js) that has `console.log("hi");` in it, and ran `node file.js`, do you see "hi" as output? – dylants Oct 29 '14 at 02:26
  • @dylants I get no output with just jasmine-node. Other node packages work fine. If I make a simple console.log test and run it with `nodejs file.js` I get the expected output. – user259743 Oct 29 '14 at 02:29
  • Just making sure, you said you ran it with `nodejs file.js`, can you run things with `node` instead of `nodejs`? Also you said other node packages work fine, do you use any others that run via the command line (like bower or grunt, etc)? – dylants Oct 29 '14 at 02:35
  • @dylants Only `nodejs` works. Apologies, it looks like jasmine-node is the first CLI tool I've installed on this machine. – user259743 Oct 29 '14 at 02:44
  • Try changing that first line of the jasmine-node script from `node` to `nodejs` to see if that works. – dylants Oct 29 '14 at 02:51
  • @dylants I actually found a solution to getting `node` to work on another SO question. Turns out it was some sort of Ubuntu apt conflict. Thank you for pointing me in that direction. Your method of changing the env to nodejs in the script worked before I got node to work. If you put it as an answer I will accept it. Thanks. – user259743 Oct 29 '14 at 03:02
  • Glad you got it working! – dylants Oct 29 '14 at 03:28

1 Answers1

3

Check that the contents of the script that you're running uses the same command that you're using when you invoke node. For instance, the contents of the jasmine-node script contains:

#!/usr/bin/env node

if( !process.env.NODE_ENV ) process.env.NODE_ENV = 'test';

var path = require('path');
require(path.join(__dirname,'../lib/jasmine-node/cli.js'));

The first line contains #!/usr/bin/env node which indicates that node is used to run the code. Verify that node is available and can execute that code.

Installation on Ubuntu machines can be complicated (since there was an old nodejs binary). I recommend using the following documentation to install Node on an Ubuntu machine: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions

Specifically it calls out using a different distribution repository. Using this in future installs helps get the correct node binary on the machine and in the PATH.

dylants
  • 22,316
  • 3
  • 26
  • 22