Cypress: Circle CI build failed

Created on 24 Jul 2018  ·  10Comments  ·  Source: cypress-io/cypress

When I try to run tests with Circle CI v2 using npm, build fails after running npm ci:

#!/bin/bash -eo pipefail
npm ci
/bin/bash: npm: command not found
Exited with code 127

This is my circleci.yml config:

version: 2
jobs:
  build:
    working_directory: /var/www
    docker:
      # using custom image, see .circleci/images/primary/Dockerfile
      - image: circleci/cci-demo-docker-primary:0.0.2
      - image: cypress/base:8
        environment:
          ...
          TERM: xterm
    parallelism: 1
    steps:
      - checkout
      - run:
          ...
      - restore_cache:
          key: v2-deps-{{ .Branch }}-{{ checksum "package.json" }}
          key: v2-deps-{{ .Branch }}-
          key: v2-deps-
      - run: npm ci
      - save_cache:
          key: v2-deps-{{ .Branch }}-{{ checksum "package.json" }}
          paths:
            - ~/.npm
            - ~/.cache
      - run: $(npm bin)/cypress run --record --key <my_record_key>

Most helpful comment

@saadaouad You'll need to run npm i locally in order to generate and commit the package-lock.json file to be read by your CI. The npm ci command exclusively uses the package-lock.json file.

All 10 comments

Remove the first image line - I think you are specifying two docker images and the first one takes precedence (- image: line)

Sent from my iPhone

On Jul 24, 2018, at 19:56, Saad Aouad notifications@github.com wrote:

When I try to running the tests in Continuous Integration using Circle CI v2 with npm, the build is failed after running npm ci:

!/bin/bash -eo pipefail

npm ci
/bin/bash: npm: command not found
Exited with code 127
This is my circleci.yml config:

version: 2
jobs:
build:
working_directory: /var/www
docker:
# using custom image, see .circleci/images/primary/Dockerfile
- image: circleci/cci-demo-docker-primary:0.0.2
- image: cypress/base:8
environment:
...
TERM: xterm
parallelism: 1
steps:
- checkout
- run:
...
- restore_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package.json" }}
key: v2-deps-{{ .Branch }}-
key: v2-deps-
- run: npm ci
- save_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ~/.npm
- ~/.cache
- run: $(npm bin)/cypress run --record --key

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Thanks, I removed it but I get another error:

#!/bin/bash -eo pipefail
npm ci
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or later to generate it, then try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-07-24T19_12_29_424Z-debug.log
Exited with code 1

@saadaouad You'll need to run npm i locally in order to generate and commit the package-lock.json file to be read by your CI. The npm ci command exclusively uses the package-lock.json file.

npm i Can not generate package-lock.json file @jennifer-shehane

@saadaouad npm install creates a package-lock by default. You must have configured npm to not generate one.

Correct @Bkucera, thanks 👍

@saadaouad You'll need to run npm i locally in order to generate and commit the package-lock.json file to be read by your CI. The npm ci command exclusively uses the package-lock.json file.

As the error message suggests, it npm ci also uses (preferentially) a npm-shrinkwrap.json file.

@saadaouad You'll need to run npm i locally in order to generate and commit the package-lock.json file to be read by your CI. The npm ci command exclusively uses the package-lock.json file.

As the error message suggests, it npm ci also uses (preferentially) a npm-shrinkwrap.json file.

Thanks atz it work for me

If you wanna use yarn instead?? = /

@stephyswe Late reply, but you can replace npm ci with yarn install --frozen-lockfile . Rest should run just fine with npm commands used in the examples they provide, I believe.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carloscheddar picture carloscheddar  ·  3Comments

scottcrowe picture scottcrowe  ·  3Comments

weskor picture weskor  ·  3Comments

simonhaenisch picture simonhaenisch  ·  3Comments

jennifer-shehane picture jennifer-shehane  ·  3Comments