nrwl / nx-console

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

NX Console Generators not working on VSCode #1977

Closed James-Coates closed 5 months ago

James-Coates commented 8 months ago

Current Behavior

All generators fail when run through NX console on VSCode with the same error. They run fine directly in terminal.

Expected Behavior

Generators to run on NX Console as they do direct in terminal. This is a regression; used to run on my configuration pre upgrade to v17.

Steps to Reproduce

Fresh nx install and commands do not run.

Failure Logs / Images / Videos

The error for all NC Console commands is the same:

Unexpected token '??='

Unexpected token '??='

Environment

MaxKless commented 8 months ago

That's weird. Can you search for ??= in your workspace? Maybe the symbol was written into some configuration file that Nx Console is trying to parse and failing? Be sure to check project.json, nx.json and package.json files too.

James-Coates commented 8 months ago

Thanks for the response. This was one of the first things I tried and have just tried again for sanity sake but there are no such references to ??=.

As mentioned this happens for me on a fresh repo using npx create-nx-workspace@latest

MaxKless commented 7 months ago

Hey! Just ran into this in another setting. Two questions:

James-Coates commented 7 months ago

Hi Max, using: Node: v18.12.1 and nvm to manage node versions

James-Coates commented 7 months ago

Just tried LTS (v20.11.0) and still same issue

MaxKless commented 7 months ago

can you toggle the 'Show Node Version On Startup' setting in Nx Console and confirm that the version used by vscode is the same as you see in your terminal?

James-Coates commented 7 months ago

Done this and can confirm the version used is the same used as terminal.

heracek commented 6 months ago

Hi, I had the same issue on my macOS and I was able to fix it.

Nx plugin reported version 18.19.1 in 'Show Node Version On Startup'. But the generator was using some old version on my system and it was failing on Unexpected token '??='

By running /bin/zsh -l -c 'node --version' and /bin/zsh -l -c 'which node' I was able to find that I had some Node.js v14 on my system.

When I remove the Node v14 it started to work again.


But I think it is not fixing the core of the issue.

I'm using FNM to manage Node.js versions.

The version reported by 'Show Node Version On Startup' (18.19.1) is correct version (I have it in .nvmrc file in root of the project). But when I run /bin/zsh -l -c 'node --version' it says v21.6.1 (which is a version of Node.js installed by Homebrew).

It seems that running /bin/zsh -l -c 'node --version' ignores the ~/.zshrc file and therefore it does not setup FNM.

Only when I run /bin/zsh -l -i -c 'node --version' (with -i for --interactive) it runs ~/.zshrc and selects at least default version provide by FNM.

James-Coates commented 6 months ago

Thanks all, I have managed to resolve the issue my end by updating the node version on my mac's homebrew to lts