【问题标题】:'gulp-babel' not working in node js version 4'gulp-babel' 在节点 js 版本 4 中不起作用
【发布时间】:2019-10-03 07:26:05
【问题描述】:

当我的 gulp 文件中需要 gulp-babel 以在我的 js 文件中使用 es6 语法时,我遇到了错误。

/home/logakrishnan/Documents/project/node_modules/@babel/core/lib/transformation/file/file.js:77
  constructor(options, {
                       ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/logakrishnan/Documents/project/node_modules/@babel/core/lib/index.js:153:36)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

节点版本:v4.4.7

【问题讨论】:

    标签: javascript jquery node.js gulp gulp-watch


    【解决方案1】:

    您必须升级您的 Node.js 版本。 (节点 4 来自 2016 年,用 JavaScript 术语来说是一个相对永恒的时间。)

    At the time of writing, Babel requires Node 6.9 or newer.

    【讨论】:

    • 除了升级node版本,还有其他解决方案吗?
    • 使用较旧的 Babel,但这可能很难。
    猜你喜欢
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    • 2019-07-18
    • 2017-05-17
    • 2021-11-27
    • 2016-04-16
    • 1970-01-01
    相关资源
    最近更新 更多