You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在运行Vitest时传递NodeJS的--enable-experimental-regexp-engine标志?

如何在Vitest中传递Node实验性正则引擎标志

你可以通过两种方式给Vitest传递Node的--enable-experimental-regexp-engine标志:

方法一:直接用Node启动Vitest入口文件

修改package.json里的test脚本,直接调用Node执行Vitest的入口文件,把Node的实验性标志放在最前面:

"scripts": {
  "test": "node --enable-experimental-regexp-engine node_modules/vitest/vitest.mjs --reporter=verbose"
}

这种方式相当于让Node带着指定标志去运行Vitest的脚本,自然会启用新的正则引擎。

方法二:使用Vitest的--node-options参数

Vitest内置了--node-options参数,专门用来传递Node的启动选项,脚本可以改成:

"scripts": {
  "test": "vitest --node-options=\"--enable-experimental-regexp-engine\" --reporter=verbose"
}

这种写法更简洁,不需要手动定位Vitest的入口文件,直接通过Vitest的参数把Node标志传进去即可。

注意:如果是Windows系统,可能需要调整引号格式,比如改用单引号或者去掉外层引号,根据实际情况调整。

内容的提问来源于stack exchange,提问作者florian norbert bepunkt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 17:32:02