【问题标题】:babel transform throw error ERROR in The node API for `babel` has been moved to `babel-core` n sublime-text3babel transform throw error `babel` 的节点 API 中的错误已移至 `babel-core` n sublime-text3
【发布时间】:2018-03-02 14:28:27
【问题描述】:

我已经在全局和本地安装了 babel-core,并在其中一个全局和本地安装了 babel-eslint macOS 10.12.6 中的 angular 项目并尝试检查 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 代码进行了很好的 linting

.eslintrc 文件有以下内容

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

现在导航到 sublime text 并单击 Tools > Babel > Babel Transform 获取 js 文件,它会立即抛出如下错误

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

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

【问题讨论】:

    标签: sublimetext3 babeljs eslint


    【解决方案1】:

    通过从项目根目录执行这两个命令解决了这个问题

    sudo npm uninstall babel --save-dev
    sudo npm install babel-loader babel-core --save-dev
    

    【讨论】:

      猜你喜欢
      • 2016-11-08
      • 2016-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-10
      • 2019-04-27
      • 2017-12-20
      相关资源
      最近更新 更多