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

Node installed with fnm isn't recognized in VS Code terminal #1317

Open
o1Suleyman opened this issue Nov 12, 2024 · 7 comments
Open

Node installed with fnm isn't recognized in VS Code terminal #1317

o1Suleyman opened this issue Nov 12, 2024 · 7 comments

Comments

@o1Suleyman
Copy link

o1Suleyman commented Nov 12, 2024

I'm using the VS Code snap on Ubuntu

@IlCallo
Copy link

IlCallo commented Nov 14, 2024

Same here, apparently since last Visual Studio Code update
Still need to dig this further

@IlCallo
Copy link

IlCallo commented Nov 14, 2024

I can confirm the problem are latest VSCode versions, in particular October version

Command to revert to revision 172 on snap: sudo snap refresh code --revision 172

First failing version (revision 173 on snap):

Version: 1.95.0
Commit: 912bb683695358a54ae0c670461738984cbb5b95
Date: 2024-10-28T20:16:24.561Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Linux x64 6.8.0-48-generic snap

Last working version (revision 172 on snap):

Version: 1.94.2
Commit: 384ff7382de624fb94dbaf6da11977bba1ecd427
Date: 2024-10-09T16:08:44.566Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Linux x64 6.8.0-48-generic snap

@o1Suleyman
Copy link
Author

thanks, does this only occur in the snap?

@IlCallo
Copy link

IlCallo commented Nov 15, 2024

Dunno, haven't tried other installation methods
Try checking out on vscode repo if anyone else had the same problem even when not using snap

@FabriBorgobello
Copy link

Same thing in MacOs

@KiringYJ
Copy link

KiringYJ commented Nov 26, 2024

I encountered the same issue on Windows and found that it was due to different profile paths being used in Windows.

Why This Happens

Visual Studio Code's integrated terminal might use PowerShell Core (pwsh) instead of Windows PowerShell, depending on your system configuration and VS Code settings. If the fnm environment setup is only in the WindowsPowerShell profile, it won't work with pwsh. The profile paths are in different folders depending on the PowerShell version:

  • The profile path for PowerShell Core (pwsh) is typically in the PowerShell folder:
    C:\Users\<YourUsername>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
    
  • The profile path for Windows PowerShell is typically in the WindowsPowerShell folder:
    C:\Users\<YourUsername>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
    

Solution

  1. Ensure the Correct Profile Path Is Configured:

    • You can check the profile path being used by running the following command in the integrated terminal:
      $PROFILE
    • Add the fnm env --use-on-cd command to the appropriate profile:
      fnm env --use-on-cd | Out-String | Invoke-Expression
  2. Restart VS Code and Test:

    • Close and reopen Visual Studio Code to ensure the profile loads properly.
    • Test by running:
      node -v
      • It should reflect the correct Node.js version based on your project settings.

After ensuring the correct profile is configured, everything should work as expected.

I hope this helps others facing the same issue!

@o1Suleyman
Copy link
Author

o1Suleyman commented Nov 26, 2024

I use neither Windows nor Powershell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants