$ babel and $ babel-node don't launch the REPL

2019-03-06 07:28发布

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?

2条回答
We Are One
2楼-- · 2019-03-06 07:34

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.

查看更多
Fickle 薄情
3楼-- · 2019-03-06 07:34

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

查看更多
登录 后发表回答