Javascript 获取节点中导入语句的语法错误
SyntaxError:意外标记* 导入语句:Javascript 获取节点中导入语句的语法错误,javascript,node.js,ecmascript-6,Javascript,Node.js,Ecmascript 6,SyntaxError:意外标记* 导入语句: import * as tst from ".//SCRIPT//CommonImport" { "type": "node", "request": "launch", "name": "Launch Current", "stopOnEntry": false, "cwd": "${workspaceFolder}", "outputCapture": "console", "progr
import * as tst from ".//SCRIPT//CommonImport"
{
"type": "node",
"request": "launch",
"name": "Launch Current",
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"outputCapture": "console",
"program": "${workspaceFolder}\\${config:debug-current.file}",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"internalConsoleOptions": "openOnSessionStart"
}
launch.json:
import * as tst from ".//SCRIPT//CommonImport"
{
"type": "node",
"request": "launch",
"name": "Launch Current",
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"outputCapture": "console",
"program": "${workspaceFolder}\\${config:debug-current.file}",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"internalConsoleOptions": "openOnSessionStart"
}
我补充说
"runtimeArgs": [ "-r", "esm" ]
您是否复制并粘贴到launch.json中的配置?因为它可能会导致您的节点版本是什么?@JackBashford 10.16.0如果我在终端中运行该命令,它就会工作。因此,在启动时,它可能不包括esm。不,它可能不包括esm——或者它可能不支持精确的导入语法。尝试从“//SCRIPT//CommonImport”导入{prop}之类的简单操作。