程序员潇然 发表于 2022-10-10 10:17:15

nodejs 安装 环境变量设置

!(data/attachment/forum/202210/10/101428a01lx12z8lqqznn6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")



解压

!(data/attachment/forum/202210/10/101444axygx1ypkptgbtgg.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


该路径下运行cmd,执行以下命令:

查看node版本

`node -v`

查看npm版本

`npm -v`

!(data/attachment/forum/202210/10/101518zrz011rf2rz7y5k1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


如果不想把npm全局模块和cache目录放到用户目录下(一般是C:\Users\AppData),建议修改一下两个目录。
在自定义位置创建node_cache和node_global两个文件夹

```bash
npm config set prefix D:\Data\Node\node_global
npm config set cache D:\Data\Node\node_cache
```

!(data/attachment/forum/202210/10/101544x1y8g0jhln8538cj.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


测试
测试并安装淘宝NPM镜像

因为npm下载资源来源国外,网络不稳定,下载也慢,安装了淘宝的镜像后使用国内cnpm资源会变得非常快。

在cmd命令提示符中输入下面的命令:

`npminstall-gcnpm--registry=https://registry.npm.taobao.org`

!(data/attachment/forum/202210/10/101601lbj1eteeax3owbb2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


!(data/attachment/forum/202210/10/101612l0bs12lz8835zla3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")

设置一下环境变量

!(data/attachment/forum/202210/10/101622itn4a8tnaf18z9qq.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")


!(data/attachment/forum/202210/10/101628mtfxftw8f0f1saje.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")
页: [1]
查看完整版本: nodejs 安装 环境变量设置