我的 package.json 中的一个脚本使用了通配符。
{
"scripts": {
"mycommand": "ls tests/**/*.ts"
}
}
我希望能够从
launch.json
配置条目运行脚本:
{
"version": "0.2.0",
"configurations": [
{
"name": "mycommand",
"type": "node",
"request": "launch",
"runtimeExecutable": "yarn",
"args": [
"mycommand"
],
"console": "integratedTerminal",
"sourceMaps": true,
"internalConsoleOptions": "neverOpen",
},
]
}
但是当我运行启动配置时,这是输出:
❯ cd /home/birger/someproject ; /usr/bin/env 'NODE_OPTIONS=--require /usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js --inspect-publish-uid=http' 'VSCODE_INSPECT
OR_OPTIONS={"inspectorIpc":"/tmp/node-cdp.165926-3a74c9d0-194.sock","deferredMode":false,"waitForDebugger":"","execPath":"/home/birger/.nvm/versions/node/v18.15.0/bin/node","onlyEntrypoint":false,"autoAttachMode"
:"always","fileCallback":"/tmp/node-debug-callback-d22722aa4becf964"}' /home/birger/.nvm/versions/node/v18.15.0/bin/yarn mycommand
Debugger attached.
yarn run v1.22.19
warning package.json: No license field
$ ls tests/**/*.ts
ls: cannot access 'tests/**/*.ts': No such file or directory
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Waiting for the debugger to disconnect...
但是如果我运行命令
yarn mycommand
(即使在与执行脚本的终端窗口相同的终端窗口中),npm 脚本执行得很好。
为什么从vscode执行命令会失败?