natn2323
natn2323

Reputation: 2061

Running npm install in a Visual Studio project's post-build event

In my project's post-build event, I have 2 tasks--run npm install and then run a gulpfile.

I'm using Azure DevOps and in my build pipeline, when npm install is run within my project's post-build event, it only runs the npm install command and not the gulpfile. It outputs:

enter image description here

However, if I run a npm install task (pointing directly to my package.json) prior to the npm install being run in my project's post-build event, then the gulpfile does get run.

I'm wondering what the issue could be here? Is it because I'm not specifying the package.json in my post-build event?

My post-build event script looks like this:

npm install
node.exe "node_modules\gulp\bin\gulp.js" --gulpfile "gulpfile.js"

Upvotes: 1

Views: 2825

Answers (1)

natn2323
natn2323

Reputation: 2061

The problem was that calling npm install directly within in the post-build event script stops the parent batch program. The way to fix this is to use the command call, documented here. That is, use call npm install.

Upvotes: 4

Related Questions