【发布时间】:2015-11-01 16:02:32
【问题描述】:
到目前为止,我使用 gulp 来构建 typescript 和 sass 文件,但现在由于几个新的构建步骤,我想统一所有内容并将节点用作单个入口点(也是通过 npm run 运行 gulp 任务的节点任务名称)。
tasks.json 很简单,任务build 应该运行npm run watch:
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"tasks": [
{
"taskName": "build",
"isBuildCommand": true,
"showOutput": "always",
"isWatching": true,
"args": [
"run", "watch"
]
}
]
}
package.json
"scripts": {
"watch": "gulp default",
}
还有输出:
gulp default build
[14:20:54] Using gulpfile PATH_TO/gulpfile.js
[14:20:54] Task 'build' is not in your gulpfile
[14:20:54] Please check the documentation for proper gulpfile formatting
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch" "build"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! 2@0.1.0 watch: `gulp default build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 2@0.1.0 watch script 'gulp default build'.
npm ERR! This is most likely a problem with the 2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! gulp default build
npm ERR! You can get their info via:
npm ERR! npm owner ls 2
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
根据输出,即使在 tasks.json 中没有任何迹象(gulpfile.json 存在于根目录中,并且在搜索解决方案时我发现 VS Code 自动检测到它,我仍然以某种方式使用 gulp假设可能是问题所在?)。此外,taskName 属性看起来像自动附加到命令行作为错误的参数。
一个较小但有效的示例(但它仍然运行 gulp,因此每次保存时都会编译两次 typescript):
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"args": [
"run", "watch"
],
"showOutput": "always"
}
如何通过 npm 在 VS Code 中执行多项任务?
【问题讨论】: