nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.82k stars 2.38k forks source link

It failed when building a next application with config `output:standalone`. #27724

Open ibufu opened 2 months ago

ibufu commented 2 months ago

Current Behavior

After integrating to an existed pnpm monorepo, it failed when building a next application with config output:standalone.

Expected Behavior

nx build next-app --verbose
Error: File exists (os error 17)
    at /nx-next-standalone/node_modules/.pnpm/nx@19.6.4/node_modules/nx/src/tasks-runner/cache.js:145:17

GitHub Repo

https://github.com/ibufu/nx-next-standalone

Steps to Reproduce

  1. Clone the repo.
  2. pnpm i
  3. nx build next-app

Nx Report

Node           : 18.20.4
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.9.0

nx (global)  : 19.6.4
nx           : 19.6.4
@nx/eslint   : 19.6.4
@nx/next     : 19.6.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/next/plugin

Failure Logs

Error: File exists (os error 17)
    at /nx-next-standalone/node_modules/.pnpm/nx@19.6.4/node_modules/nx/src/tasks-runner/cache.js:145:17

Package Manager Version

pnpm@9.9.0

Operating System

Additional Information

No response

jackhefoong commented 3 weeks ago

Same here

malfianrasyidin commented 3 weeks ago

The issue persists in the latest Nx version (v20.0.11). Is there any additional action planned to address this? @jaysoo @ndcunningham

Thanks!

Error: File exists (os error 17)
    at /node_modules/.pnpm/nx@20.0.11/node_modules/nx/src/tasks-runner/cache.js:317:17
ibufu commented 3 weeks ago

Just delete the scripts in package.json and only keep scripts in project.json

On Fri, 8 Nov 2024 at 1:22 PM Muhammad Alfian Rasyidin < @.***> wrote:

The issue persists in the latest Nx version (v20.0.11). Is there any additional action planned to address this? @jaysoo https://github.com/jaysoo @ndcunningham https://github.com/ndcunningham

Thanks!

Error: File exists (os error 17) at @.***/node_modules/nx/src/tasks-runner/cache.js:317:17

— Reply to this email directly, view it on GitHub https://github.com/nrwl/nx/issues/27724#issuecomment-2464214065, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5TWOAZONARH6NVIGBKFGTZ7R7G3AVCNFSM6AAAAABNOPB2H6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRUGIYTIMBWGU . You are receiving this because you authored the thread.Message ID: @.***>

jackhefoong commented 3 weeks ago

Big help, thanks! @ibufu

counterbeing commented 2 weeks ago

I'm getting the same error.

I'm trying to understand how not using package.json scripts would help? I'm also trying to understand how to update my project.json to actually build correctly.I went with a package.json script for this particular library because it has a couple of steps:

    "bundle": "tsx ./src/bundle.ts",
    "build": "rm -rf ./dist && tsc -p tsconfig.lib.json && pnpm run bundle"
  }

How would i convert that into a project.json syntax, and how would that fix the problem? Or would it?

ibufu commented 2 weeks ago

The root cause is that nx run the build script twice. You can use nx show to figure out it.

counterbeing commented 2 weeks ago

I've moved to this structure in my project.json for this package:

{
  "name": "workflow-bundler",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "packages/workflow-bundler/src",
  "projectType": "library",
  "tags": [],
  "targets": {
    "build": {
      "executor": "nx:run-commands",
      "options": {
        "command": "say 'hello';rm -rf ./dist && tsc -p tsconfig.lib.json && tsx ./src/bundle.ts"
      }
    }
  }
}

That say 'hello' is just there so i can hear if it happens to run twice. It's now only running once. I've entirely removed the scripts section from my package.json. However i'm still getting:

    at /Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:84:24
    at _try (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:397:26)
    at _try (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:406:26)
    at async _try (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:406:20)
    at async _try (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:406:20)
    at async _try (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:406:20)
    at async _try (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/cache.js:406:20)
    at async Promise.all (index 0)
    at async TaskOrchestrator.postRunSteps (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/task-orchestrator.js:345:13)
    at async TaskOrchestrator.applyFromCacheOrRunTask (/Users/cory.logan/Code/my-project/node_modules/.pnpm/nx@20.0.10_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.13__@swc+types@0.1.12_t_rpge6wb46b7rpyw5yhycwpxahy/node_modules/nx/src/tasks-runner/task-orchestrator.js:295:9)