babel变换抛出错误ERROR在'babel`的节点API中已被移动到`babel-core` n sublime-text3

时间:2017-09-21 09:38:09

标签: sublimetext3 babel eslint

我在全球和本地安装了 babel-core babel-eslint macOS 10.12.6 中的角度项目,并尝试检查sublime -text3中的功能os babel和eslint(build 3143

npm install -g babel-cli
npm install -g babel-eslint --save-dev

还安装在sublime-text3包下面运行和lint js文件

在项目根目录中也有 .eslintrc .jshintrc 文件,到目前为止它正在使js代码很好

.eslintrc 文件的内容低于

{
    "parser": "babel-eslint",
    "extends": "eslint:recommended"
    // other rules and global variables
}

现在导航到sublime文本,然后点击工具> Babel> js文件的Babel Transform ,它会立即抛出错误,如下所示

Error: /opt/project/node_modules/babel/index.js:1
(function (exports, require, module, __filename, __dirname) { throw new Error("The node API for `babel` has been moved to `babel-core`.");
                                                          ^

Error: The node API for `babel` has been moved to `babel-core`.
    at Object.<anonymous> (/opt/project/node_modules/babel/index.js:1:69)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at /Users/keshav.m/Library/Application Support/Sublime Text 3/Packages/Babel/babel-transform.js:23:29
    at /Users/keshav.m/Library/Application Support/Sublime Text 3/Packages/Babel/node_modules/resolve/lib/async.js:44:21

有人请告诉我这里有什么问题吗?

1 个答案:

答案 0 :(得分:1)

通过从项目根目录

执行这两个命令来解决此问题
sudo npm uninstall babel --save-dev
sudo npm install babel-loader babel-core --save-dev