Building a Node.js Application with Azure DevOps


2 min read

Step 1: Prerequisites

Step 2: Set up Azure Repos and Create a Repository

  1. In your Azure DevOps organization, navigate to your project.

  2. Click on "Repos" in the left menu.

  3. Create a new repository or use an existing one to host your Node.js code.

Step 3: Create the Build Pipeline

  1. Go to your Azure DevOps project and navigate to the "Pipelines" section.

  2. Click on "Create Pipeline" to create a new pipeline.

  3. Select your source repository (GitHub) and choose the repository that contains your Node.js code.

  4. Azure DevOps will automatically detect the type of code repository and suggest a template. If it doesn't suggest one, select "Node.js" from the list of templates.\

  5. Azure DevOps will generate a YAML file for the pipeline configuration. Review the YAML file and make sure it's correct for your Node.js project. You can customize it further as needed.

Step 4: Build your package and publish an artifact

  1. Edit your azure-pipelines.yml file.

  2. Update the Node.js Tool Installer task to use Node.js version 16 LTS.

     # Node.js
     # Build a general Node.js project with npm.
     # Add steps that analyze code, save build artifacts, deploy, and more:
     - main
       vmImage: ubuntu-latest
     - task: NodeTool@0
         versionSpec: '16.x'
       displayName: 'Install Node.js'
     - script: |
         npm install
         npm run build
       displayName: 'npm install and build'
  3. Click "Save & Run" to save your pipeline and trigger the build


  4. Azure DevOps will execute the pipeline, and you'll see the build progress


  5. If everything is set up correctly, the pipeline should successfully build your Node.js project.

Pipeline set up in Azure DevOps - Auto pulls & builds Node.js project on 'main' branch code changes. Happy coding! ๐Ÿš€

Did you find this article valuable?

Support Edvin Dsouza by becoming a sponsor. Any amount is appreciated!