简体   繁体   English

$ babel和$ babel-node不会启动REPL

[英]$ babel and $ babel-node don't launch the REPL

I'm trying to setup babel on Ubuntu 14.04 but it doesn't seem to be working! 我正在尝试在Ubuntu 14.04上设置babel,但似乎无法正常工作!

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. 当我执行babelbabel-node ,提示仅返回。 The same happens on executing the commands with a filename as argument. 在执行以文件名作为参数的命令时,也会发生同样的情况。 (The file has just console.log("hello") . (该文件只有console.log("hello")

How do I fix this? 我该如何解决?

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. /usr/sbin/node vs /usr/bin/nodejs问题已在“ 无法在Ubuntu中使用节点软件包管理器安装软件包”中解决,但基本上Ubuntu拥有一个单独的node软件包,而不是Node.js。 The package for Node.js on Ubuntu is called nodejs . Ubuntu上的Node.js软件包称为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 . 一种选择是将nodejs符号链接到node

The best solution however would be to use something like nvm to install node for your user without installing it globally. 但是,最好的解决方案是使用nvm类的nvm为您的用户安装节点,而无需全局安装。 Then you can install and update node versions extremely easily, and your PATH will always reference node properly. 然后,您可以非常轻松地安装和更新节点版本,并且PATH将始终正确引用node

/usr/local/bin/babel-node/usr/local/bin/babel的第一行nodejs node更改为nodejs解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM