I am deploying a nodejs site via Octopus Deploy. After the new site has been deployed to the appropriate folder, but before I switch the IIS site to point at the new folder, I need to run “npm install” from the command line.
Can anyone provide an example, in any of the three scripting languages Octopus supports, of how to run a command line as part of the deployment process?
Thanks for getting in touch! You can run commands in a predeploy script. You can write the custom script in your package step itself within the web portal, or include it in your package. Our custom scripts docs show these options.
We have an example in our demo site that you can check out.
I hope this helps! Let me know how you go and if you’re hitting any specific errors or issues.
Thanks Kenny. It looks like I was making this a lot harder than it needed to be. In the end my PowerShell script is just this-
$installDirectory = $OctopusParameters[‘Octopus.Action.Package.CustomInstallationDirectory’]
npm install --silent
It’s all working fine now. Appreciate your help.
That’s great to hear! Thanks for taking the time to let me know your solution. Don’t hesitate to reach out with any further questions anytime.