gpt4 book ai didi

gulp - 为什么 "gulp-jest"失败并显示 : "Please run node with the --harmony flag!"?

转载 作者:行者123 更新时间:2023-12-03 13:41:19 27 4
gpt4 key购买 nike

运行gulp test时出现以下错误:

Error: Please run node with the --harmony flag!

这是我的 gulp 任务:

var jest = require('gulp-jest');

gulp.task('test', function() {
return gulp.src('src/**/__tests__').pipe(jest({
rootDir: 'src',
scriptPreprocessor: '../node_modules/6to5-jest',
unmockedModulePathPatterns: [ 'react' ]
}));
});

重现:https://github.com/SEEK-Jobs/react-playground

请注意,npm test 工作正常(测试按预期失败),但 gulp test 失败并出现上述错误。 npm testgulp test 都有相同的配置对象:

{
rootDir: 'src',
scriptPreprocessor: '../node_modules/6to5-jest',
unmockedModulePathPatterns: [ 'react' ]
}

我做错了什么?

最佳答案

据我所知,错误是从 jest-cli 引发的。

您没有通过 npm test 获得它的原因是您可能将 npm 配置为直接运行 jest bin 脚本,该脚本使用 harmonize以编程方式设置 --harmony 标志。

您可以通过安装 Harmonize 并将 require('harmonize')() 放入 gulpfile 来修复。

关于gulp - 为什么 "gulp-jest"失败并显示 : "Please run node with the --harmony flag!"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28315796/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com