Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nx Generate Fails #20551

Closed
joshua-auchincloss opened this issue Dec 4, 2023 · 8 comments
Closed

Nx Generate Fails #20551

joshua-auchincloss opened this issue Dec 4, 2023 · 8 comments
Assignees

Comments

@joshua-auchincloss
Copy link

Current Behavior

NX fails to generate new workspaces.

Command

(base) $ pnpm create create-nx-workspace@latest
.pnpm/store/v3/tmp/dlx-89764             |  +67 +++++++
.pnpm/store/v3/tmp/dlx-89764             | Progress: resolved 67, reused 66, downloaded 1, added 67, done

 >  NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · front
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · none
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · abc
✔ Which bundler would you like to use? · vite
✔ Test runner to use for end to end (E2E) tests · playwright
✔ Default stylesheet format · css
✔ Enable distributed caching to make your CI faster · No

 >  NX   Creating your v17.1.3 workspace.

   To make sure the command works reliably in all environments, and that the preset is applied correctly,
   Nx will run "pnpm install" several times. Please wait.

✔ Installing dependencies with pnpm
✖ Creating your workspace in front

 >  NX   Failed to create a workspace.

   Exit code: 1
   Log file: /var/folders/71/fcxvkhr51hdc7vv3gs_q64sc0000gn/T/tmp-89766-UDCsrCjBfakF/error.log

Expected Behavior

The command to work and create a new monorepo.

GitHub Repo

No response

Steps to Reproduce

  1. run pnpm create create-nx-workspace@latest on macos 11 (x86)

Nx Report

>  NX   The current directory isn't part of an Nx workspace.

   To create a workspace run:
   npx create-nx-workspace@latest <workspace name>
   
   To add Nx to an existing workspace with a workspace-specific nx.json, run:
   npx nx@latest init


 >  NX   For more information please visit https://nx.dev/

Side note: why would a CLI not allow you to even run --help outside of a workspace directory?



### Failure Logs

```shell
## Error Log

Progress: resolved 1, reused 0, downloaded 0, added 0
Progress: resolved 127, reused 116, downloaded 2, added 0
Progress: resolved 269, reused 258, downloaded 2, added 0
Progress: resolved 455, reused 442, downloaded 2, added 0
Progress: resolved 570, reused 532, downloaded 7, added 0
Packages: +560
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 586, reused 548, downloaded 8, added 23
Progress: resolved 586, reused 548, downloaded 8, added 427
Progress: resolved 586, reused 548, downloaded 8, added 560, done
.../[email protected]/node_modules/esbuild postinstall$ node install.js
.../[email protected]/node_modules/esbuild postinstall: Done

devDependencies:
+ @nx/cypress 17.1.3
+ @nx/react 17.1.3
+ @nx/vite 17.1.3
+ @nx/workspace 17.1.3
+ nx 17.1.3

The dependency was already listed in devDependencies.
If you want to make it a prod dependency, then move it manually.

Done in 8s
ERROR (1) when writing 
ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~a533be78'
Error: ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~a533be78'
    at writeFileSync (node:fs:2352:20)
    at writeJsonFile (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/fileutils.js:55:28)
    at writeCache (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/nx-deps-cache.js:101:43)
    at buildProjectGraphUsingProjectFileMap (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/build-project-graph.js:65:40)
    at async buildProjectGraphWithoutDaemon (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:72:27)
    at async createProjectGraphAsync (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:121:25)
    at async Object.generate (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/generate.js:214:26)
    at async Object.handler (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/command-object.js:13:22)
ERROR (2) when writing 
ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~0d0a7374'
Error: ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~0d0a7374'
    at writeFileSync (node:fs:2352:20)
    at writeJsonFile (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/fileutils.js:55:28)
    at writeCache (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/nx-deps-cache.js:101:43)
    at buildProjectGraphUsingProjectFileMap (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/build-project-graph.js:65:40)
    at async buildProjectGraphWithoutDaemon (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:72:27)
    at async createProjectGraphAsync (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:121:25)
    at async Object.generate (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/generate.js:214:26)
    at async Object.handler (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/command-object.js:13:22)
ERROR (3) when writing 
ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~3a9fcf25'
Error: ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~3a9fcf25'
    at writeFileSync (node:fs:2352:20)
    at writeJsonFile (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/fileutils.js:55:28)
    at writeCache (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/nx-deps-cache.js:101:43)
    at buildProjectGraphUsingProjectFileMap (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/build-project-graph.js:65:40)
    at async buildProjectGraphWithoutDaemon (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:72:27)
    at async createProjectGraphAsync (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:121:25)
    at async Object.generate (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/generate.js:214:26)
    at async Object.handler (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/command-object.js:13:22)
ERROR (4) when writing 
ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~ff182791'
Error: ENOENT: no such file or directory, open '/path/to/front/.nx/cache/project-graph.json~ff182791'
    at writeFileSync (node:fs:2352:20)
    at writeJsonFile (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/utils/fileutils.js:55:28)
    at writeCache (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/nx-deps-cache.js:101:43)
    at buildProjectGraphUsingProjectFileMap (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/build-project-graph.js:65:40)
    at async buildProjectGraphWithoutDaemon (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:72:27)
    at async createProjectGraphAsync (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/project-graph.js:121:25)
    at async Object.generate (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/generate.js:214:26)
    at async Object.handler (/path/to/front/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/generate/command-object.js:13:22)

>  NX  Generating @nx/workspace:preset


 >  NX   ENOENT: no such file or directory, open '/var/folders/71/fcxvkhr51hdc7vv3gs_q64sc0000gn/T/tmp-89848-tN6tAagVK1EZ/package.json'

   Pass --verbose to see the stacktrace.


 >  NX   Workspace creation failed, see above.

   Pass --verbose to see the stacktrace.


### Package Manager Version

pnpm 8.11.0

### Operating System

- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)

### Additional Information

_No response_
@MHarmony
Copy link

MHarmony commented Dec 4, 2023

Having the same issue. Latest NX version, pnpm 8.11.0, node 21.3.0.

@joshua-auchincloss
Copy link
Author

Having the same issue. Latest NX version, pnpm 8.11.0, node 21.3.0.

It actually blew up all my other projects lol - getting the following error on already working source code after trying to generate a new lib


> nx run abc:serve:development

Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.

If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.

If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
    at readCachedProjectGraph (/path/to/proj/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/project-graph.js:30:15)
    at run (/path/to/proj/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/command-line/run/run.js:151:69)
    at process.<anonymous> (/path/to/proj/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/bin/run-executor.js:59:48)
    at process.emit (node:events:519:28)
    at emit (node:internal/child_process:951:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

 ———————————————————————————————————

@joshua-auchincloss
Copy link
Author

Works on lts/iron, temp fix by downgrading node from 21 -> 20 if anyone has the same issue until triage

@jase88
Copy link

jase88 commented Dec 4, 2023

Same error here with nx 17.1.3 and node 21.3.0
downgrading to 20 helped thanks!

@ysageev
Copy link

ysageev commented Dec 6, 2023

Same dealio

@ghost
Copy link

ghost commented Jan 9, 2024

Same issue with nx 16.8.1 and node 18.10.0 on mac.

It is consistently breaking when changing branches, so might have something to do with invalid cache / state?
I don't use distributed cache.

I figured out a workaround by deleting the .nx folder completely and running my task again.

@AgentEnder AgentEnder added the scope: core core nx functionality label Jan 28, 2024
Copy link

This issue has been automatically marked as stale because it hasn't had any activity for 6 months.
Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore.
If at this point, this is still an issue, please respond with updated information.
It will be closed in 21 days if no further activity occurs.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Nov 10, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2024
Copy link

github-actions bot commented Jan 1, 2025

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants