0
votes

Apologies in advance that I can't share source for this one:

I've got a client that has to use Azure DevOps Pipelines to build a github enterprise hosted project.

It is a perfectly regular node.js project with jest specified as a devDependency in package.json.

When the npm install runs on an Azure Pipeline, jest doesn't get installed. I created a local x64 linux agent on Ubuntu 18 on my desktop, and it doesn't get installed their either but when I manually run npm install inside the /s/ directory it's all okay.

What is Azure Devops doing to the script that this is the result?

1
Hi @Billy Back Bedroom, it could work as expected when I run npm install in azure pipeline. I have shared some steps in the answer. You could check if it is similar with yours. If I missed key points, feel free to let me know.Kevin Lu-MSFT

1 Answers

0
votes

What is Azure Devops doing to the script that this is the result?

Test to run Npm install in Azure Pipeline and local machine, it seems that they have the same behavior. The Jest will be installed in node_modules folder.

Here are my steps, you could refer to it.

  1. The File structure. I also add the jest to devDependency in package.json.

File

"devDependencies": {
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.3",
"jest": "^22.4.3"
}
  1. Use the Npm install task in Azure Pipeline.

    - task: Npm@1
       displayName: 'npm install'
       inputs:
         workingDir: package
         verbose: false
    
  2. Run the pipeline and the Jest will be installed in the node_modules folder.

Result

By the way, I test the same steps on the Microsoft-hosted agents: ubuntu-18.04 and it could work fine.

Updates

For running Npm install with the Script:

Here is an example:

steps:
- script: |
   cd $(build.sourcesdirectory)/package
    
   npm install 
  displayName: 'Command Line Script'

The first step is used to navigate to the source folder(contains package.json file).

Then the jest will be installed.