Babel安装无法通过npm运行

aka*_*ord 6 javascript install babel npm ecmascript-6

我正试图通过跟随这个安装ES6,但是我的终端出错了.这是我在做npm install后看到的--global babel

/usr/local/bin/babel -> /usr/local/lib/node_modules/babel/cli.js
/usr/local/bin/babel-node -> /usr/local/lib/node_modules/babel/cli.js
/usr/local/bin/babel-external-helpers -> /usr/local/lib/node_modules/babel/cli.js
babel@6.5.2 /usr/local/lib/node_modules/babel
Run Code Online (Sandbox Code Playgroud)

当我输入babel-node时

You have mistakenly installed the `babel` package, which is a no-op in Babel 6.
Babel's CLI commands have been moved from the `babel` package to the `babel-cli` package.

    npm uninstall babel
    npm install babel-cli

See http://babeljs.io/docs/usage/cli/ for setup instructions.
Run Code Online (Sandbox Code Playgroud)

当我尝试npm卸载babel时,我得到了与之前相同的响应

Lin*_*ury 6

用这个.

npm install --global babel-cli
Run Code Online (Sandbox Code Playgroud)

这将全局安装并完美运行.并检查你的package.json,是否在dev依赖项下创建了babel-cli节点:

"devDependencies": {"babel-cli": "^6.14.0"}
Run Code Online (Sandbox Code Playgroud)


Dav*_*kro 1

It's easy! you need path babel

For example

sudo ./node_modules/babel-cli/bin/babel.js --watch es6.js --out-file es5.js
Run Code Online (Sandbox Code Playgroud)