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

nvm-desktop: command not found: {lib} #23

Closed
1111mp opened this issue Nov 22, 2023 · 14 comments
Closed

nvm-desktop: command not found: {lib} #23

1111mp opened this issue Nov 22, 2023 · 14 comments
Labels
documentation Improvements or additions to documentation stale

Comments

@1111mp
Copy link
Owner

1111mp commented Nov 22, 2023

This issue aims to explain why the nvm-desktop: command not found prompt message appears. Only applies to the following two situations:

  • Set the prefix option of npm. (npm config set prefix "/path/to/folder") That is the directory of the "npm" global installation package has been changed.
  • When using yarn or pnpm through corepack. (corepack enable --install-directory /path/to/folder) The directory where the executable is generated was changed via the --install-directory option.

Therefore, the error prompt of nvm-desktop: command not found in the terminal is in line with its respective default behavior. At this time, you need to manually add the /path/to/folder directory path to the system environment variable, and then terminal can be correctly identified. However, please note that when adding it to the system environment variable, you need to put the path of /path/to/folder before nvmd ($HOME/.nvmd/bin).

You can download a node version separately to test its respective default behavior without using nvm-desktop.


这个 issue 旨在解释为何出现 nvm-desktop: command not found 提示信息。 只适用于以下两种情况:

  • 设置过npmprefix选项。 (npm config set prefix "/path/to/folder") 即npm全局安装包的目录已更改。
  • 通过corepack使用yarnpnpm时。 (corepack enable --install-directory /path/to/folder) 通过 --install-directory 选项更改了可执行文件生成的目录。

终端中出现nvm-desktop: command not find的错误提示符合其各自的默认行为的。 这时需要手动将/path/to/folder目录路径添加到系统环境变量中,然后终端才能正确识别。不过请注意,在添加到系统环境变量的时候,需要将/path/to/folder的路径放在nvmd$HOME/.nvmd/bin) 之前。

你可以在不使用nvm-desktop的情况下单独下载一个node的版本到本地进行测试。当更改过npm的全局包安装路径以及通过corepack enable --install-directory /path/to/folder命令生成yarn&pnpm的可执行文件时,需要将其对应的路径添加到环境变量中之后终端才能够正确识别。

Reference:

When in global mode, executables are linked into {prefix}/bin on Unix, or directly into {prefix} on Windows. Ensure that path is in your terminal's PATH environment to run them.

Corepack is a zero-runtime-dependency Node.js script that acts as a bridge between Node.js projects and the package managers they are intended to be used with during development. In practical terms, Corepack lets you use Yarn, npm, and pnpm without having to install them.

corepack enable --install-directory /path/to/folder

Add the Corepack shims to the install directories

When run, this commmand will check whether the shims for the specified package
managers can be found with the correct values inside the install directory. If
not, or if they don't exist, they will be created.

By default it will locate the install directory by running the equivalent of
which corepack, but this can be tweaked by explicitly passing the install
directory via the --install-directory flag.

@rmd1710714107
Copy link

卸载后仍然出现nvm-desktop: command not found:node,这个如何解决?

@1111mp
Copy link
Owner Author

1111mp commented Nov 30, 2023

@rmd1710714107 根据文档完全卸载nvm-desktop: uninstall

@rmd1710714107
Copy link

@rmd1710714107 根据文档完全卸载nvm-desktop: uninstall

感谢,已解决

Copy link

This issue is stale because it has been open for 30 days with no activity.

Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@overrei
Copy link

overrei commented Sep 11, 2024

你好,我按照上面的说明,把环境变量也设置了,顺序也调整了。全局安装yarn后,依然报错nvm-desktop: command not found: "yarn"

@1111mp
Copy link
Owner Author

1111mp commented Sep 12, 2024

@overrei 请问这边更改过npm的全局安装路径吗

如果没有更改的话,正常情况下通过 npm install yarn -g 安装之后,在 %HOMPATH%\.nvmd\bin 目录下会多出这些文件:
image
你可以检查一下你电脑上该目录下是否存在这些目录 然后确保 %HOMPATH%\.nvmd\bin 已经被添加到系统环境变量中(将%HOMEPATH%替换成自己电脑的完整路径:比如我自己的:C:\Users\1111mp\.nvmd\bin

然后如果你更改过npm的全局安装包路径的话 比如我本地通过 npm config set prefix "C:\Users\1111mp\.npm_global" 更改了全局安装包路径 这时候我运行 npm install -g @vue/cli 那么在 C:\Users\1111mp\.npm_global 目录下会安装如下文件:
image

如果这时候我没有将其加入到环境变量,直接运行 vue --version,那么控制台也会报:nvm-desktop: command not found: "vue",但是如果我将其加入到环境变量中:
image
然后重新打开一个终端运行:vue --version,这时候就正常了,打印:@vue/cli 5.0.8
image

所以你按照这个步骤验证一下看看哪里有问题呢 比如在执行这些命令过程中 终端有报错吗 或者执行 nvmd --help 是否正常

@overrei
Copy link

overrei commented Sep 12, 2024

@1111mp 谢谢你的说明
我本地的C:\Users\admin.nvmd\bin目录和更改的npm全局安装包路径下都已经有yarn文件了,环境变量我按照你的截图,把全路径也配置了。
image
image
image
这些都配置好后,执行yarn -v依然提示nvm-desktop: command not found: "yarn"
image
执行nvmd --help也可以正常显示
image

@1111mp
Copy link
Owner Author

1111mp commented Sep 12, 2024

@overrei 你需要把 D:\nvm-desktop\node_global 上移一个位置 在 C:\Users\admin\.nvmd\bin 上面

然后再重启一下终端运行一下 yarn --version 看能否正常

@overrei
Copy link

overrei commented Sep 12, 2024

@1111mp
我试了下,好像还是不行
image
终端也是重启了
image

@1111mp
Copy link
Owner Author

1111mp commented Sep 12, 2024

@overrei 这个yarn是在当前的node版本下安装的吗 你可以重新安装一下试试 npm install yarn -g 然后再执行 yarn -v 看看

如果还是不行 那应该就是之前应该在没改npm的prefix之前已经全局安装了yarn 然后更改之后又安装了一次 然后系统变量虽然都加了 但是两者可能有冲突 你可以试着将 C:\Users\admin\.nvmd\bin 目录下所有的 yarn相关的文件都手动删除一下 然后再执行 yarn -v 试试能不能用

@overrei
Copy link

overrei commented Sep 12, 2024

@1111mp 终于好了,就像你说的。我把C:\Users\admin\.nvmd\bin目录下的yarn相关文件一删就好了。感谢感谢!

@Coder-LzZ
Copy link

请问一下 这个node_global是干啥的

@1111mp
Copy link
Owner Author

1111mp commented Sep 18, 2024

@Coder-LzZ npm 通过 npm config set prefix "/path/to/folder" 命令设置的全局安装包安装路径

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

No branches or pull requests

4 participants