npm - VS Code and tasks with node -
until used gulp building typescript , sass files, due couple of new build steps i'd unify , use node single entry point (also node running gulp tasks via npm run taskname).
tasks.json quite simple, task build
should run 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", }
and output:
gulp default build [14:20:54] using gulpfile path_to/gulpfile.js [14:20:54] task 'build' not in gulpfile [14:20:54] please check documentation 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 @ 2@0.1.0 watch script 'gulp default build'. npm err! problem 2 package, npm err! not npm itself. npm err! tell author fails on system: npm err! gulp default build npm err! can info via: npm err! npm owner ls 2 npm err! there additional logging output above. npm err! please include following file support request:
based on output, gulp still somehow used thought there no sign of in tasks.json
(gulpfile.json
exists in root directory , while searching solution found vs code auto detects it, assume might problem?). taskname
property looks automatically appended command line argument wrong.
a smaller working example (but still runs gulp therefore typescript compiled twice on each save):
{ "version": "0.1.0", "command": "npm", "isshellcommand": true, "args": [ "run", "watch" ], "showoutput": "always" }
how can have multiple tasks in vs code through npm?
as mentioned in comments, if you're looking run npm scripts tasks vs code, this article instructs create .vscode\tasks.json
following:
{ "version": "0.1.0", "command": "npm", "isshellcommand": true, "suppresstaskname": true, "tasks": [ { // build task, ctrl+shift+b // "npm install --loglevel info" "taskname": "install", "isbuildcommand": true, "args": ["install", "--loglevel", "info"] }, { // test task, ctrl+shift+t // "npm test" "taskname": "test", "istestcommand": true, "args": ["test"] }, { // "npm run lint" "taskname": "lint", "args": ["run", "lint"] } ] }
as alternative, there's sample vs code extension microsoft aimed @ detecting , running npm scripts items: vscode-npm-scripts
Comments
Post a Comment