从vscode调试运行时出现错误Cannot use import statement outside a module
。
当我从命令行运行mocha时,它运行正常。
VSCode配置:
{
"args": [
"test",
"--require @babel/register"
],
"internalConsoleOptions": "openOnSessionStart",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/mocha",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
有效的命令行:./node_modules/mocha/bin/mocha test --require @babel/register --exit
答案 0 :(得分:0)
此配置对我有用
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/node_modules/mocha/bin/mocha",
"args": [
"test",
"--require", "@babel/register",
"--timeout", "999999",
"--colors"
],
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
"runtimeArgs": ["--nolazy"]
}
我也将babel-cli
的依赖项中的所有圣经软件包都更新为7.x,并用@babel/cli
进行了更改