Win配置node环境
测了半天,用到如下工具:msys2、scoop、pnpm,具体操作如下:
安装nodejs
scoop install nodejs
设置npm目录
npm config ls
npm config get prefix \\获取当前设置的目录
npm config set prefix \\设置node_modules目录
npm root -g \\全局位置
安装pnpm
corepack enable pnpm@latest
ref
Since v16.13, Node.js is shipping Corepack for managing package managers. This is an experimental feature, so you need to enable it by running:
info
If you have installed Node.js with pnpm env Corepack won't be installed on your system, you will need to install it separately. See #4029.
$ corepack enable pnpm
配置镜像源:
pnpm add nnrm -g
nnrm use taobao
设置pnpm目录
pnpm c get \\获取pnpm当前目录
pnpm config set global-bin-dir cache-dir state-dir global-dir "" \\设置pnpm目录
node版本管理
$ pnpm env use -g 18
在"~/.bashrc"中加一条"alias node = "C:/Users/whens/AppData/Local/pnpm/node.exe""
$ source ~/.bashrc
$ node -v
尽情玩耍吧!!!