如何用gulp-babel定位节点

问题描述 投票:0回答:1

我试图将我的咖啡代码转换为在gulp任务中运行mocha测试。

我得到[BABEL] /some/path/example.js:未知选项:.targets。查看https://babeljs.io/docs/en/babel-core/#options以获取有关选项的更多信息。

以下是gulp任务的相关部分:

      .pipe(sourcemaps.init())
      .pipe(gulpif(isCoffee, coffee({ bare: true })))
      .pipe(babel({ presets: [
          '@babel/preset-env', {
            targets: {
              node: "11.10"
            }
          }
        ]
      } ))
      .pipe(sourcemaps.write('.'))
      .pipe(mocha({ reporter: 'list' }));
    }

依赖关系是:

“@ babel / cli”:“^ 7.2.3”“@ babel / core”:“^ 7.3.3”“@ babel / preset-env”:“^ 7.3.1”“@ babel / register”:“^ 7.0.0“......”gulp“:”^ 4.0.0“”gulp-babel“:”^ 8.0.0“......

并且选项记录了here

我想我一定错过了某个地方的备忘录!

node.js gulp coffeescript mocha
1个回答
-1
投票

啊哈!这缺少一对方括号:预设应包含一个数组数组,每个内部数组包含一个预设名称和可选的选项映射。

        [   
          'preset-name', {
            options-key: 'option value'
          }
        ]
      ]
    })).etcetera ```     
© www.soinside.com 2019 - 2024. All rights reserved.