Leah Zorychta
Leah Zorychta

Reputation: 13419

Calling nodejs scripts from the command line does not work

This is what my file test.js contains:

console.log("Hello Stackoverflow");

This is what happens when I attempt to run it:

$ ls
test.js
$ node test.js
$ node test
$ node "test"
$ node "test.js"
$ node --debug test.js
debugger listening on port 5858
$ node --debug test
debugger listening on port 5858
$ 

Notice that it never works :( I can run just "node" and evaluate javascript statements line by line but whenever I try to run a script as above it does not work.

I'm running OS X 10.8 and a brand new installation of nodejs.

Upvotes: 2

Views: 350

Answers (1)

Leah Zorychta
Leah Zorychta

Reputation: 13419

The solution to my problem was to uninstall node using:

sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}

I then installed brew on my mac:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

And then I did

brew doctor

I fixed the issues it told me to fix from that, and then I did

brew install node

I then restarted terminal, and node was working.

Upvotes: 2

Related Questions