Fino ad ora ho utilizzato gulp per la creazione di file dattiloscritto e sass, ma ora a causa di un paio di nuove fasi di generazione vorrei unificare tutto e utilizzare il nodo come un singolo punto di ingresso (anche nodo per eseguendo attività di gulp via npm, eseguire taskName).VS Codice e attività con il nodo
tasks.json è abbastanza semplice, compito build
dovrebbe funzionare 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",
}
E l'output:
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! [email protected] watch: `gulp default build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:
Sulla base della uscita, gulp è ancora in qualche modo usato anche se non ci sono segni di esso in tasks.json
(gulpfile.json
esiste nella directory principale e durante la ricerca di una soluzione ho scoperto che VS Code lo rileva automaticamente, che presumo possa essere il problema?). Anche la proprietà taskName
sembra essere aggiunta automaticamente alla riga di comando come argomento errato.
Un esempio piccolo ma lavorare (ma funziona ancora sorso quindi dattiloscritto è compilato due volte su ogni salvataggio):
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"args": [
"run", "watch"
],
"showOutput": "always"
}
Come posso avere più attività con in codice VS attraverso NPM?
Sto cercando una soluzione simile pure. Per quanto riguarda il taskName aggiunto alla riga di comando, cercare la proprietà di configurazione 'suppressTaskName' come accennato [qui] (http://scottaddie.com/2015/10/07/harnessing-webpack-with-visual-studio-code/) – superjos
, dare un'occhiata a [questo] (https://dlaa.me/blog/post/vscodenodetask) per vedere come eseguire le attività degli script npm dal codice VS – superjos