We call Gulp from our csproj file as we're using Visual Studio 2013 for this project:
<Target Name="AfterBuild"> <Exec Command="gulp" /> </Target> However, since we're still crafting this fresh project, we often extend the gulpfile.js to include new packages. The dev will do e.g. npm install gulp-util --save-dev and write a new task, and all is well.
The developer then checks the gulpfile.js and packages.json in to our VCS. Currently:
npm install;npm install manually;Having to remember something that has to be done manually is not a great spot to be in. At one point we had this in our csproj file inside the Task...
<Exec command="npm install" /> ...just before the gulp exec, so developers could not "forget" to take this manual step. However, this can take one or even multiple seconds on each (re)build, which is annoying.
Is there any better way to solve this? How do you handle updates to packages.json in projects where large(ish) teams develop using Visual Studio?
The npm clean-install command (or npm ci for short) is an in-place replacement for npm install with two major differences: It does a clean install: if the node_modules folder exists, npm deletes it and installs a fresh one. It checks for consistency: if package-lock.
No, once you run npm install, packages should be downloaded/installed in the node_modules folder.
npm install , or npm i , is used to install dependencies: It will install all the dependencies. If you use ^ or ~ when you specify the version of your dependency, npm may not install the exact version you specified. npm install can update your package-lock.
There is no difference, since "npm i" is an alias for "npm install". They both do the exact same thing (install or update all the dependencies in your package-lock.
An approach that works for me is to use MSBuild incremental build support in combination with a stamp file:
<PropertyGroup> <!-- File with mtime of last successful npm install --> <NpmInstallStampFile>node_modules/.install-stamp</NpmInstallStampFile> </PropertyGroup> <Target Name="NpmInstall" BeforeTargets="BeforeBuild" Inputs="package.json" Outputs="$(NpmInstallStampFile)"> <Exec Command="npm install" /> <Touch Files="$(NpmInstallStampFile)" AlwaysCreate="true" /> </Target> The NpmInstall Target only runs when package.json is newer than node_modules/.install-stamp and it touches that file after a successful npm install. This way npm install is only run once after each change to package.json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With