When using yarn to install vite, the installation fails no matter what, and it prompts "'D:\Program' is not an internal or external command, nor is it an operable program or batch file.",
yarn create v1.22.18
[1/4] Resolving packages...
warning [email protected]: create-vite-app has been deprecated. run `npm init @vitejs/app` or `yarn create @vitejs/app` instead.
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
- create-vite-app
- cva
[##############] 14/14'D:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
error Command failed.
Exit code: 1
Command: D:\Program Files\nodejs\node_global\bin\create-vite-app
Arguments:
Directory: D:\Program Files\nodejs\node_global
Output:
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
According to online information, changing the global and cache is not enough, and finally found a useful information,
'D:\Program' is not recognized as an internal or external command, operable program;
Cause: node installation directory D:\Program Files\nodejs, there is a space in the middle
Solution: reinstall nodejs, the installation directory should not contain spaces.
Attach the URL:
npm, yarn to set the global installation location and cache location - short book prerequisite node installation D disk: D:\nodejs, initially installed in D:\Program Files\nodejs, but the use of yarn encountered some errors. npm settings are in the nodejs file... https://www.jianshu.com/p/30ba1da2bde1
In the next step, I will focus on how to move node out of Program Files.
1. Copy the entire directory of nodejs
to
D:\nodejs
2. Modify the global environment of node.
1) Modify cache and global
npm config set cache "D:\nodejs\node_cache"
npm config set prefix "D:\nodejs\node_global"
2) Modify system environment variables
Path modify these two places: "D:\nodejs\" and "D:\nodejs\node_global";
NODE_PATH: D:\nodejs\node_global\node_modules
able to pass
The where node command checks the current node installation path, and
the npm root -g command checks the current node's global installation environment.