纱线安装错误:NX无法读取未定义的属性(Reading' Endswith')

发布于 2025-02-13 21:05:43 字数 2759 浏览 1 评论 0原文

我正在尝试在React应用程序的NX Workspace中设置Circeci。

  • 在执行纱线安装的步骤中,
  • 我会得到下一个错误:

error/home/circleci/project/node_modules/@nrwl/js/node_modules/nx, /home/circleci/project/node_modules/@nrwl/remix/node_modules/nx: 命令失败。退出代码:1命令:节点./bin/init参数: 目录: /home/circleci/project/node_modules/@nrwl/js/node_modules/nx输出:

nx无法读取未定义的属性(读取'endswith')信息访问 https:// yarnpkg .com/en/doc/cli/install 用于文档 此命令。

带有代码退出状态1

退出

这是我的Circeci配置,

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

有人有类似的问题吗?

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

  • On the step where is executed yarn install
  • I get next error:

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蔚蓝源自深海 2025-02-20 21:05:43

我很多次都解决了这个问题。
只需删除node_modules中的“ .cache/nx”文件夹,然后重新运行命令。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文