version-fox / vfox

A cross-platform and extendable version manager with support for Java, Node.js, Flutter, .Net & more
https://vfox.lhan.me
Apache License 2.0
2.68k stars 95 forks source link

Switch node version not working #35

Closed baymax55 closed 7 months ago

baymax55 commented 7 months ago

Version VersionFox version 0.2.2 OS Windows 11 Pro for Workstations Insider Preview 64-bit (10.0,Build 26040)

Describe the bug Switch node version not working

Screenshots[optional] image

aooohan commented 7 months ago

What nodejs plugin version are you using? You can use vfox info node command to look at plugin version.

In addition, according to the prompt, you have not configured the hook correctly, please refer to the following steps to configure the hook:

# For PowerShell, add the following line to your $PROFILE:
Invoke-Expression "$(vfox activate pwsh)"
baymax55 commented 7 months ago

Same for java image

ShizheChang commented 7 months ago

您所报告的问题上确实存在一个bug,即:在windows环境下,cmd与powershell应当能够在未经任何配置的情况下即可开箱使用。但为了更好的使用体验, 对于powershell有正确的配置方案:

  1. 在powershell中使用$PROFILE命令确认配置文件路径。若该文件不存在,则可能需要您手动新建一个;
  2. 在上一步寻得的文件中,增加一行配置: Invoke-Expression "$(vfox activate pwsh)"
  3. 重新打开powershell。由于windows的默认策略,在上述动作完成后,也许您会看到关于powershell的配置脚本被禁用的提示。如果您见到了该提示,那么请参考:about_execution_policies来解决该问题。 一般来说您可以通过执行Set-ExecutionPolicy -ExecutionPolicy RemoteSigned来允许配置脚本可运行。 在完成上述操作后,即可重新打开powershell使用vfox!

btw, vfox默认session作用域

Indeed, the issue you've reported is a bug: in a Windows environment, both cmd and PowerShell should be ready to use out of the box without any configuration. However, to enhance the user experience, we have a proper configuration procedure for PowerShell:

  1. In PowerShell, use the $PROFILE command to confirm the path of the configuration file. If this file does not exist, you may need to manually create one.
  2. In the file found in the first step, add the following configuration line: Invoke-Expression "$(vfox activate pwsh)".
  3. Reopen PowerShell. Due to Windows' default policy, after completing the above steps, you might see a prompt indicating that the PowerShell configuration script has been disabled. If you encounter this prompt, you can refer to about_execution_policies to resolve this issue. Typically, you can allow the configuration script to run by executing Set-ExecutionPolicy -ExecutionPolicy RemoteSigned.
  4. After completing the above steps, you can reopen PowerShell and use vfox!

Please note, by default, the scope of vfox is set to session.

baymax55 commented 7 months ago

Adding Invoke-Expression "$(vfox activate pwsh)" in the configuration file is work for me.

Thanks.

您所报告的问题上确实存在一个bug,即:在windows环境下,cmd与powershell应当能够在未经任何配置的情况下即可开箱使用。但为了更好的使用体验, 对于powershell有正确的配置方案:

  1. 在powershell中使用$PROFILE命令确认配置文件路径。若该文件不存在,则可能需要您手动新建一个;
  2. 在上一步寻得的文件中,增加一行配置: Invoke-Expression "$(vfox activate pwsh)"
  3. 重新打开powershell。由于windows的默认策略,在上述动作完成后,也许您会看到关于powershell的配置脚本被禁用的提示。如果您见到了该提示,那么请参考:about_execution_policies来解决该问题。 一般来说您可以通过执行Set-ExecutionPolicy -ExecutionPolicy RemoteSigned来允许配置脚本可运行。 在完成上述操作后,即可重新打开powershell使用vfox!

btw, vfox默认session作用域

Indeed, the issue you've reported is a bug: in a Windows environment, both cmd and PowerShell should be ready to use out of the box without any configuration. However, to enhance the user experience, we have a proper configuration procedure for PowerShell:

  1. In PowerShell, use the $PROFILE command to confirm the path of the configuration file. If this file does not exist, you may need to manually create one.
  2. In the file found in the first step, add the following configuration line: Invoke-Expression "$(vfox activate pwsh)".
  3. Reopen PowerShell. Due to Windows' default policy, after completing the above steps, you might see a prompt indicating that the PowerShell configuration script has been disabled. If you encounter this prompt, you can refer to about_execution_policies to resolve this issue. Typically, you can allow the configuration script to run by executing Set-ExecutionPolicy -ExecutionPolicy RemoteSigned.
  4. After completing the above steps, you can reopen PowerShell and use vfox!

Please note, by default, the scope of vfox is set to session.

baymax55 commented 7 months ago

Sorry, I'm confused, it seems only work for Java, but not for Node and Golang

image

aooohan commented 7 months ago

@baymax55 Can you post your screenshot of $PROFILE configuration content?

image
baymax55 commented 7 months ago

@baymax55 Can you post your screenshot of $PROFILE configuration content?

image

@aooohan image

aooohan commented 7 months ago

@baymax55 Everything looks fine.

You installed Node16.20.1 and Golang 1.19.4 separately, not through vfox, right? If so, you need to uninstall it first as vfox will configure the user variables for you, if you configure the system variables manually, windows will prioritize the PATH in the system variables.

baymax55 commented 7 months ago

@baymax55 Everything looks fine.

You installed Node16.20.1 and Golang 1.19.4 separately, not through vfox, right? If so, you need to uninstall it first as vfox will configure the user variables for you, if you configure the system variables manually, windows will prioritize the PATH in the system variables.

Yes, I installed Node16.20.1 and Golang 1.19.4 separately.

I will try to reinstall it

baymax55 commented 7 months ago

Reinstall it still can not switch Node and Golang version

aooohan commented 7 months ago

Alright, please post your $PATH content by $env:path command. Note that you need to reopen Powershell

baymax55 commented 7 months ago

Alright, please post your $PATH content by $env:path command. Note that you need to reopen Powershell

C:\Program Files\PowerShell\7;C:\Users\Dell\AppData\Local\Programs\Python\Python311;D:\devPrograms\go1.19.4.windows-amd64\go\bin;C:\telepresence;C:\Program Files\SSHFS-Win\bin;C:\Users\Dell\Documents\PowerShell\Modules\oh-my-posh;C:\Program Files\PowerShell\7;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\devPrograms\apache-maven-3.6.3\bin;D:\sysPrograms\TortoiseSVN\bin;D:\devPrograms\go\lib\time;C:\ProgramData\chocolatey\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;D:\devPrograms\cwrsync\bin;D:\devPrograms\node-v16.20.1-win-x64;C:\Users\Dell\scoop\shims;"D:\devPrograms\Fiddler;C:\Users\Dell\AppData\Local\Microsoft\WindowsApps;C:\Users\Dell\.dotnet\tools;C:\Users\Dell\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\Dell\AppDa";D:\devPrograms\Fiddler;C:\Users\Dell\AppData\Local\Microsoft\WindowsApps;D:\devPrograms\jdk\jdk-17_windows-x64_bin\jdk-17\bin;C:\metasploit-framework\bin\;D:\devPrograms\scrcpy-win64-v1.25;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Tailscale\;C:\Program Files\Cloudflare\Cloudflare WARP\;D:\devPrograms\Git\cmd;D:\devPrograms\flutter_windows_3.16.3-stable\flutter\bin;C:\Program Files\PowerShell\7\;;;C:\Program Files\vfox;C:\Users\Dell\.version-fox\cache\nodejs\v-14.9.0\nodejs-14.9.0;C:\Users\Dell\.version-fox\cache\java\v-21\java-21/bin;C:\Users\Dell\.version-fox\cache\java\v-11\java-11/bin;C:\Users\Dell\.version-fox\cache\nodejs\v-21.6.1\nodejs-21.6.1;C:\Users\Dell\AppData\Local\pnpm;C:\Users\Dell\scoop\shims;C:\Users\Dell\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\Dell\AppData\Local\Programs\Python\Python311\;C:\Users\Dell\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\Lens\resources\cli\bin;C:\Program Files (x86)\Nmap;C:\Users\Dell\AppData\Local\Programs\Microsoft VS Code\bin

aooohan commented 7 months ago

As I said above, you need to delete the PATH you configured yourself. The path priority you configured yourself is higher than that of vfox, so it seems that vfox has never taken effect.

image
baymax55 commented 7 months ago

As I said above, you need to delete the PATH you configured yourself. The path priority you configured yourself is higher than that of vfox, so it seems that vfox has never taken effect. image

I just deleted the environment variables of node and golang, but it still doesn't work. As you said, the environment variable priority of java 17 is also higher than that of vfox, why does it work? @aooohan image

aooohan commented 7 months ago

There's no good way to do this, only check the PATH from the user variable and the system variable. Find it and remove.

image

aooohan commented 7 months ago

Since this has nothing to do with vfox, I will close this issue, wish you good luck.

baymax55 commented 7 months ago

in addition: I didn't do anything. I just installed nvm and took over the node version downloaded by vfox. I can switch the node version normally using nvm.

image

aooohan commented 7 months ago

@baymax55 https://discord.gg/JAuHXJ2b Come in and talk.