nrwl / nx-console

Nx Console is the user interface for Nx & Lerna.
https://nx.dev
MIT License
1.31k stars 211 forks source link

Nx commands have suddendly started to create the .nx folder on the project root folder instead node_modules on version 16.10 #1975

Closed andreaSimonePorceddu closed 9 months ago

andreaSimonePorceddu commented 10 months ago

Current Behavior

Since this morning, I have issues running the nx command with no changes to the codebase or dependencies:

Screenshot 2024-01-04 alle 14 22 31

I'm using the last 16 version 16.10.0, node version 18.18.

"@nrwl/js": "16.10.0",
"@nx/cypress": "16.10.0",
"@nx/detox": "16.10.0",
"@nx/eslint-plugin": "16.10.0",
"@nx/jest": "16.10.0",
"@nx/js": "16.10.0",
"@nx/linter": "16.10.0",
"@nx/next": "16.10.0",
"@nx/react": "16.10.0",
"@nx/react-native": "16.10.0",
"@nx/storybook": "16.10.0",
"@nx/web": "16.10.0",
"@nx/webpack": "16.10.0",
"@nx/workspace": "16.10.0",

I wonder if it could be related to yesterday's release of the 17 (some common dependencies changed).

Expected Behavior

No error and nx command successfully executed, cache still placed on node_modules

GitHub Repo

No response

Steps to Reproduce

Run an nx command

Nx Report

shell
Node   : 18.18.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx                 : 16.10.0
   @nx/js             : 16.10.0
   @nx/jest           : 16.10.0
   @nx/linter         : 16.10.0
   @nx/workspace      : 16.10.0
   @nx/cypress        : 16.10.0
   @nx/detox          : 16.10.0
   @nx/devkit         : 16.10.0
   @nx/eslint-plugin  : 16.10.0
   @nx/next           : 16.10.0
   @nx/react          : 16.10.0
   @nx/react-native   : 16.10.0
   @nx/storybook      : 16.10.0
   @nrwl/tao          : 16.10.0
   @nx/web            : 16.10.0
   @nx/webpack        : 16.10.0
   nx-cloud           : 16.5.2
   typescript         : 4.9.4
   ---------------------------------------
   Community plugins:
   @jscutlery/semver : 2.29.3

Failure Logs

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 (/Users/app/node_modules/nx/src/project-graph/project-graph.js:30:15)
    at run (/Users/app/node_modules/nx/src/command-line/run/run.js:151:69)
    at process.<anonymous> (/Users/app/node_modules/nx/bin/run-executor.js:59:48)
    at process.emit (node:events:517:28)
    at emit (node:internal/child_process:944:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

Package Manager Version

1.22.19

Operating System

Additional Information

No response

andreaSimonePorceddu commented 10 months ago

I managed to fix it by running: yarn nx reset

Closing the issue.

andreaSimonePorceddu commented 10 months ago

Sorry, I'm going to reopen this, because, anyway, nx has started to create the .nx folder in the root folder, instead of into the node_modules folder. I saw that this change should be from 17 version but we are still using the 16.

Any idea about it?

Erbenos commented 10 months ago

Experiencing same thing I am not anyhow associated to the issue author.

andreaSimonePorceddu commented 10 months ago

@Erbenos when it started to do it?

Erbenos commented 10 months ago

Yesterday 10am GMT.

nx report:

 >  NX   Report complete - copy this into the issue template

   Node   : 16.15.1
   OS     : darwin-arm64
   npm    : 8.11.0

   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/angular        : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nx/nest           : 16.7.4
   @nx/node           : 16.7.4
   @nx/plugin         : 16.7.4
   @nx/storybook      : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/web            : 16.7.4
   @nx/webpack        : 16.7.4
   nx-cloud           : 16.4.0
   typescript         : 5.1.6

      Community plugins:
   @compodoc/compodoc           : 1.1.21
   @storybook/angular           : 7.4.0
   ngx-daterangepicker-material : 6.0.4
   ngx-toastr                   : 17.0.2
   nx-stylelint                 : 15.0.0

   <omitting workspace plugins>

Removing all cache folders manually allows commands to pass for a time, but they eventually again degrade to the error you already provided.

andreaSimonePorceddu commented 10 months ago

Yesterday 10am GMT.

node -v v16.15.1 npm -v 8.11.0

Mac

nx-report all green. Removing all cache folders manually allows commands to pass for a time, but they eventually again degrade to the error you already provided.

The same for me, which nx version are u using?

AgentEnder commented 10 months ago

The cache location changed in v17 - if you downgrade to nx 16 you'd need to run nx reset potentially to refresh the daemon (and also not have a .nx folder present, as that's picked up and used if its already there in v16+) otherwise it'll be recreated.

Swapping between version 16 + 17 on different braches or similar can thus be a bit messy.

@Erbenos what does nx report look like?

Erbenos commented 10 months ago

Attached report to https://github.com/nrwl/nx-console/issues/1975. No downgrade ever took place as I never were on 17.

andreaSimonePorceddu commented 10 months ago

@AgentEnder I never switched from 17 to 16, I always used the 16. I checked the yarn.lock and I've no reference to the 17. Do you have some remote reference when launching nx commands?

wrenzi commented 10 months ago

I'm experiencing the same scenario. It started happening yesterday.

   Node   : 20.10.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nx/plugin         : 16.7.4
   @nx/react          : 16.7.4
   @nx/rollup         : 16.7.4
   @nx/storybook      : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/web            : 16.7.4
   @nx/webpack        : 16.7.4
   nx-cloud           : 16.5.2
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @mands/nx-playwright        : 0.6.2
   @nx-aws-plugin/nx-aws-cache : 3.1.0
AgentEnder commented 10 months ago

Ah, I think this is due to Nx console using a v17 install of Nx that's not present in the workspace, which creates the .nx folder and then it fails when the default changes over to .nx but there's not expected info in there.

I'm going to transfer this over to the console repo to be worked, I don't have the context to know why console would not be picking up your installation.

Hotell commented 9 months ago

we are facing same issue https://github.com/microsoft/fluentui-contrib

this makes nx console not usable for more than 1 project unfortunately. would be great if it would always use workspace installed nx version and only if not present fall back to global one.

MaxKless commented 9 months ago

Hey! Sorry for the slow response. I'm super busy with things right now but I should have time to look into this next week. Something is happening on initialization that's wrong...

MaxKless commented 9 months ago

Hey! I just pushed a PR that should fix this. I'll cut a release soon and would be very grateful for your feedback on whether any issues persist on your end. When you upgrade, please make sure to run nx reset, delete the .nx folder and restart vscode just to be sure to clean any weird leftover state.

stavalfi commented 3 months ago

it doesn't work @MaxKless . I have nx@19.1.0

MaxKless commented 3 months ago

hey @stavalfi couks you create a new issue with a detailed description of the error and your nx report? Then we can have a look again :)