Mark James
Mark James

Reputation: 568

Yarn install error: NX Cannot read properties of undefined (reading 'endsWith')

I am trying to setup circeci in NX workspace for react app.

error /home/circleci/project/node_modules/@nrwl/js/node_modules/nx, /home/circleci/project/node_modules/@nrwl/remix/node_modules/nx: Command failed. Exit code: 1 Command: node ./bin/init Arguments: Directory: /home/circleci/project/node_modules/@nrwl/js/node_modules/nx Output:

NX Cannot read properties of undefined (reading 'endsWith') info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Exited with code exit status 1

This is my circeci config

version: 2.1

orbs:
  nx: nrwl/[email protected]

jobs:
  agent:
    resource_class: xlarge
    docker:
      - image: cimg/node:lts-browsers
    parameters:
      ordinal:
        type: integer
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: | 
            yarn install 
      - run:
          name: Start the agent << parameters.ordinal >>
          command: yarn nx-cloud start-agent
          no_output_timeout: 60m
  main:
    resource_class: xlarge
    docker:
      - image: cimg/node:lts-browsers
    environment:
      NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: |
            yarn install 
      - nx/set-shas:
          main-branch-name: 'main'
      - run:
          name: Initialize the Nx Cloud distributed CI run
          command: yarn nx-cloud start-ci-run
      - run:
          name: Run workspace lint
          command: yarn nx-cloud record -- yarn nx workspace-lint
      - run:
          name: Check format
          command: yarn nx-cloud record -- yarn nx format:check --base=$NX_BASE --head=$NX_HEAD
      - run:
          name: Run lint
          command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
      - run:
          name: Run test
          command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
      - run:
          name: Run build
          command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
      - run:
          name: Stop all agents
          command: yarn nx-cloud stop-all-agents
          when: always

workflows:
  version: 2

  ci:
    jobs:
      - agent:
          name: Nx Cloud Agent << matrix.ordinal >>
          matrix:
            parameters:
              ordinal: [1, 2, 3]
      - main:
          name: Nx Cloud Main

Does anyone had similar problem?

Upvotes: 1

Views: 9793

Answers (1)

Chalom.E
Chalom.E

Reputation: 697

I encount this issue a lot of times. Just remove the ".cache/nx" folder in your node_modules and re-run your command.

Upvotes: 2

Related Questions