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
提示信息。 只适用于以下两种情况:
- 设置过
npm
的prefix
选项。 (npm config set prefix "/path/to/folder"
) 即npm
全局安装包的目录已更改。
- 通过
corepack
使用yarn
或pnpm
时。 (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.