npm ci instead of npm install in NodeJs Azure Function App

Olga Andreeva 126 Reputation points
2024-09-05T08:03:12.77+00:00

I am using SCM_DO_BUILD_DURING_DEPLOYMENT feature in my Azure Function App written in NodeJs. I would like to customize the install behavior logic so that instead of npm install npm ci the command is run. Could anyone advise what should I do to achieve this?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,039 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Khadeer Ali 245 Reputation points Microsoft Vendor
    2024-10-15T02:12:19.6733333+00:00

    Hi @Olga Andreeva,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    If you want to use npm ci instead of npm install. We can achieve this but before replacing we need to follow the below steps.

    1. Before using npm ci, make sure your project has either a package-lock.json or yarn.lock file. These files lock down the dependency versions, ensuring consistent installations across different environments.
    2. If you're using a custom build process, you can directly replace npm install with npm ci in your build script.
    3. If you're using the default build process in Azure Functions, you'll need to modify the build script that Azure Functions uses. This script is typically located in the functions directory of your project.
    4. Open the build script (e.g., build.sh or build.cmd) and find the line that executes npm install and replace that line with the npm ci
    5. Deploy your updated Function App to Azure. The deployment process will now use npm ci to install dependencies.

    If you find this answer helpful, please click "Comment" and kindly upvote it.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.