0

I'm trying to setup babel on Ubuntu 14.04 but it doesn't seem to be working!

Here are some outputs that may be required:

$ which node
/usr/sbin/node
$ which nodejs
/usr/bin/nodejs
$ which babel
/usr/local/bin/babel
$ which babel-node
/usr/local/bin/babel-node

When I execute babel or babel-node the prompt just returns. The same happens on executing the commands with a filename as argument. (The file has just console.log("hello").

How do I fix this?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
rohithpr
  • 6,050
  • 8
  • 36
  • 60

2 Answers2

1

The /usr/sbin/node vs /usr/bin/nodejs issue has been covered in Cannot install packages using node package manager in Ubuntu but basically Ubuntu has a separate node package that is NOT Node.js. The package for Node.js on Ubuntu is called nodejs. If you have both installed, it means your scripts will try to run using the other unrelated application. One option is to symlink nodejs to node.

The best solution however would be to use something like nvm to install node for your user without installing it globally. Then you can install and update node versions extremely easily, and your PATH will always reference node properly.

Community
  • 1
  • 1
loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
0

Changing node to nodejs in the first line of /usr/local/bin/babel-node and /usr/local/bin/babel solves it.

rohithpr
  • 6,050
  • 8
  • 36
  • 60
  • Changing the globally installed scripts is not a good idea. If you're not actually using `/usr/sbin/node` remove it and symlink it to `nodejs` so it affects all scripts. Or use `nvm` and install node for your user. – loganfsmyth Aug 30 '15 at 15:36
  • @loganfsmyth - I didn't know about nvm. Thanks for mentioning it! Could you please turn your comment into an answer? – rohithpr Aug 30 '15 at 15:41