尝试使用不在根文件夹中的VSCode运行gulp任务

Flo*_*ehn 23 gulp visual-studio-code

这是我的task.json

// A task runner configuration for gulp. Gulp provides a less task
// which compiles less to css. 
{
    "version": "0.1.0",
    "command": "gulp",
    "isShellCommand": true,
    "tasks": [
        {
            "taskName": "sfdcBuild",
            // Make this the default build command.
            "isBuildCommand": true,
            // Show the output window only if unrecognized errors occur.
            "showOutput": "always",
            // Use the standard less compilation problem matcher.
            "problemMatcher": "$lessCompile"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

不幸的是我的gulp安装(本地安装)不在root下但在另一个文件夹中:

root/js/
Run Code Online (Sandbox Code Playgroud)

那么如何定义我想从其他文件夹中运行这个gulp命令?

PS:将task.json移动到子文件夹中也没有用.

Dir*_*mer 35

部分支持使用不同的工作目录.它不适用于自动检测gulp任务,但它应该适用于运行gulp.您可以将这样的内容添加到顶级作用域中的tasks.json中

"options": {
    "cwd": "${workspaceRoot}/mySubDir"
},
Run Code Online (Sandbox Code Playgroud)

但是,这仍然假设gulp和guld所需的所有节点模块都可以从该目录访问.