Azure pipeline: Command Line error: Bash exited with code '1'

While attempting to run my Cypress test using Azure Pipeline, I encountered the following problem:

YAML file:

# To configure triggers for Azure CI see
# https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#tags
jobs:
  - job: Cypress_tests
    pool:
      vmImage: 'ubuntu-22.04'
    # Runs tests in parallel https://docs.cypress.io/guides/guides/parallelization
    # https://learn.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml
    strategy:
      parallel: 2
    steps:
      - task: NodeTool@0
      # Caches dependencies using npm lock file as key
      # https://docs.cypress.io/guides/continuous-integration/introduction#Caching
      - task: CacheBeta@1
        inputs:
          key: npm | package-lock.json
          path: /home/vsts/.npm
          restoreKeys: npm | package-lock.json
      - task: CacheBeta@1
        inputs:
          key: cy | package-lock.json
          path: /home/vsts/.cache/Cypress
          restoreKeys: cy | package-lock.json
      - script: npm ci --prefer-offline
      # Starts web server for E2E tests - replace with your own server invocation
      # https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
      - script: npm start &
      - script: npx wait-on 'http-get://localhost:3000' # Waits for above
      # Runs tests in parallel and records to Cypress Cloud
      # https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
      # https://docs.cypress.io/guides/guides/parallelization
      - script: npx cypress run --record --parallel --ci-build-id $BUILD_BUILDNUMBER
        # For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
        # in Azure DevOps → Your Pipeline → Edit → Variables
        env:
          CYPRESS_RECORD_KEY: $(CYPRESS_RECORD_KEY)

Error:

Starting: CmdLine
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.212.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
npm ci --prefer-offline
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/82c8b231-ced2-40c3-9bca-ec69d4282405.sh

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, tag, team, test, tst, un, uninstall,
    unpublish, unstar, up, update, v, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:

Answer №1

When running the NodeTool@0 command without any parameters, it sets the active node version to 6. It seems that the ci command may not have existed at that time. Be sure to choose a more recent version of Node:

versionSpec - Version Spec

string. Optional. Use when versionSource = spec. Default value: 6.x.

Specifies the version spec of the version to get. Examples: 6.x, 4.x, 6.10.0, >=6.10.0.

- task: NodeTool@0
  inputs:
    versionSpec: "18.x"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps to remove a package from the npm registry

Is it feasible to eliminate or erase a complete module from the npm registry? Please be aware that using npm -f unpublish does not permit the deletion of packages older than 24 hours. ...

Encountered a surprise JSON ERROR during installation of a React Native package

I encountered an issue while trying to add the firebase package to my React Native project. npm i --save firebase When running the above command, I received the following error: npm ERR! Unexpected end of JSON input while parsing near '...5L/bQQbhWxI ...

Creating a NodeJS package that automatically compiles C++/WebAssembly during installation

What is the best way to structure a NodeJS package that includes wrapped C++ code compiled into web assembly? How can we ensure that the compilation step takes place when using npm install <package name>? I have developed a package called mypackage ...

Unable to globally install "npm install -g yo" - it can only be installed locally

Having trouble installing jhipster due to an issue with the yo version installation. npm install -g yo However, when running Yeoman Doctor, it shows that the yo version is outdated. Yeoman Doctor Running sanity checks on your system ✔ Global configur ...

I encounter a Runtime Error after attempting to upgrade my Ionic2 project to Ionic3. Can anyone help me troubleshoot this

Code Error There was a problem with the module build: Error: ENOENT: no such file or directory, open '/Users/.../src/constants/Strings.js.map' at Error (native) typescript": "2.3.4" Application Information Global Packages: @ionic/cli-utils : ...

Troubleshooting npm errors during code deployment in AWS CodeBuild pipeline

Issue encountered during the initial deployment of code. After merging the code successfully, an error occurred while running 'npm ci' in CodeBuild. The pipeline indicates success upon code merge, but the npm command throws the following error: ...

The command 'start-react-native-app' is not identified as an internal or external command, executable program, or script file

Currently, I am tackling the challenge of developing a React Native application. To my dismay, when running 'create-react-native-app', the message 'create-react-native-app' is not recognized as an internal or external command, operable ...

When trying to use 'npm start' in create-react-app, I ran into issues even with freshly created applications. The errors were being thrown within the chokidar node_module

Encountered an error when trying to start 'test_app' using 'npm start' on a newly created application with 'create-react-app'. This issue is also present in previously created projects using create-react-app. I've attempt ...

Utilize npm workspaces to refresh the package.json files nested within package-lock.json

I am utilizing npm workspaces to manage a monorepo. One thing I've noticed is that the top-level package-lock.json contains a cached version of each workspace's package.json in its "package" field. How can I update these cached versions without a ...

Tips for generating a code coverage report in react-create-app!

Every time I attempt to run the tests with coverage using npm test --coverage, the tests pass but the coverage is not generated. After making a modification in the package.json file to include react-scripts test --coverage, running npm test followed by a ...

Is there a way to log into yarn without needing to interact with it manually?

One way to login non-interactively using npm is: $ printf "jesstelford\n<password>\<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b151e031a160b171e3b1e161a121755181416">[email protected]</a>&bsol ...

Utilizing NPM Package Configuration Variables with Docker Commands: A Guide

I have a unique file structure where my package.json contains a single variable called settings which defines the port for the application: package.json ... "settings":{ "port": "3000" }, ... In addition, I've set up a custom script to execute a ...

Guide on installing Node.js package dependencies manually

I'm a newcomer to Node.js and currently navigating the challenges of working on a project within a highly restrictive firewall environment, without access to npm or a proxy. I've managed to incorporate express by storing the files locally and req ...

What is the purpose of running the command 'npm outdated --depth=0' in order to compare discrepancies?

After executing the command npm outdated --depth=0, I noticed the following: Package Current Wanted Latest Location cordova 5.4.1 5.4.1 6.0.0 cordova grunt-angular- ...

Bundle Angular library exports along with its corresponding models

I am in the process of developing an angular library for our company's private npm repository. Within this library, I aim to export classes that are utilized (injected via @Input()) in the library components. Here is a sample model: export class AdsT ...

Warning message triggered by grunt-bowercopy indicating that no files were successfully copied

I have configured Grunt to compile compass with a watch task, and now I wish to copy specific files from bower_components/... - like bower_components/jquery/jquery.min.js. This is because Bower generates many unnecessary files that I want to exclude when u ...

Understanding the Difference Between WARN and ERR in npm Peer Dependency Resolution

I encountered a puzzling situation where two projects faced the same issue, yet npm resolved them differently: https://github.com/Sairyss/domain-driven-hexagon npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! W ...

Encountered a RangeError with NPM due to an invalid triggerAsyncId while trying to install Node.js 12.6.0 on Windows 10

Encountering a challenge after installing Nodejs v12.6.0 on Windows 10 Pro. Node version retrieval works fine, but attempting to check the NPM version returns an error. As a result, I am unable to run my Node application on this machine due to this issue. ...

Ensuring the value of a v-text-field in Vuetify using Cypress

I am currently developing an end-to-end test suite using Cypress for my Vue and Vuetify frontend framework. My goal is to evaluate the value of a read-only v-text-field, which displays a computed property based on user input. The implementation of my v-tex ...

Eliminating Angular's @Injectable decorator in npm build process

I have encountered a setback while working on a small helper package for Angular. The issue I am facing is related to an exported class that serves as an Angular service and is decorated with @Injectable(). After running npm run build, the compiled class ...