记一下 Windows11 安装与配置 node.js 的标准步骤

简介: 这篇文章记录了在Windows 11系统上安装和配置Node.js的步骤,包括安装Node.js、验证安装、配置npm、设置npm镜像加速、全局安装cnpm并配置镜像、解决TLS连接不安全警告的详细过程。

1、首先随便下载个 node.js 的x86或x64.msi安装包,双击直接安装,安装的路径如"C:\Program Files\nodejs\";

2、安装完成后,打开 cmd 命令控制符,输入查看版本命令来验证是否安装成功;

Microsoft Windows [版本 10.0.17134.376]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>node -v
v18.14.2

C:\Users\Administrator>npm -v
9.5.0

C:\Users\Administrator>

3、接下来配置 npm,打开 cmd 命令控制符,输入以下两条指令;

C:\Users\Administrator>npm config set prefix "C:\Program Files\nodejs\node_global"

C:\Users\Administrator>npm config set cache "C:\Program Files\nodejs\node_cache"

4、镜像加速,若只能连公司内网就用公司镜像仓库,若可以连外网可以用其他镜像仓库;

C:\Users\Administrator>npm config set registry https://registry.npm.taobao.org

C:\Users\Administrator>npm config get registry
https://registry.npm.taobao.org/

也可以全局安装 cnpm 并设置为淘宝镜像,当导入项目依赖时,像使用 npm install 一样,直接使用 cnpm install 命令即可。

C:\Users\Administrator>npm install -g cnpm --registry=https://registry.npm.taobao.org

接下来打开 cmd 命令控制符,输入查看 cnpm 版本命令,但是这里会报错。因为 cnpm 会被安装到 nodejs\node_global 里面,而系统变量 path 并未包含该路径,在系统变量path下加上该路径。

重新打开 命令控制符,输入查看版本命令。

C:\Users\Administrator>cnpm -v
cnpm@8.3.0 (C:\Program Files\nodejs\node_global\node_modules\cnpm\lib\parse_argv.js)
npm@8.19.1 (C:\Program Files\nodejs\node_global\node_modules\cnpm\node_modules\npm\index.js)
node@12.16.2 (C:\Program Files\nodejs\node.exe)
npminstall@6.5.1 (C:\Program Files\nodejs\node_global\node_modules\cnpm\node_modules\npminstall\lib\index.js)
prefix=C:\Program Files\nodejs\node_global
win32 x64 10.0.22000
registry=https://registry.npmmirror.com

C:\Users\Administrator>

5、解决报错【Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)】

npm config set strict-ssl false
目录
相关文章
|
6天前
|
数据安全/隐私保护 Windows
安装 Windows Server 2019
安装 Windows Server 2019
|
6天前
|
Windows
安装 Windows Server 2003
安装 Windows Server 2003
|
7天前
|
NoSQL Shell MongoDB
Windows 平台安装 MongoDB
10月更文挑战第10天
15 0
Windows 平台安装 MongoDB
|
10天前
|
Windows Python
Windows安装dlib,遇到问题汇总解决
Windows安装dlib,遇到问题汇总解决
20 4
|
14天前
|
Oracle 关系型数据库 MySQL
Mysql(1)—简介及Windows环境下载安装
MySQL 是一个流行的关系型数据库管理系统(RDBMS),基于 SQL 进行操作。它由瑞典 MySQL AB 公司开发,后被 Sun Microsystems 收购,现为 Oracle 产品。MySQL 是最广泛使用的开源数据库之一,适用于 Web 应用程序、数据仓库和企业应用。
46 2
|
15天前
|
JavaScript Windows
windows安装vue
windows安装vue
|
15天前
|
JavaScript 开发工具 git
已安装nodejs但是安装hexo报错
已安装nodejs但是安装hexo报错
19 2
|
16天前
|
应用服务中间件 Apache Windows
免安装版的Tomcat注册为windows服务
免安装版的Tomcat注册为windows服务
25 3
|
6天前
|
Windows
安装Windows XP系统
安装Windows XP系统
|
29天前
|
存储 JavaScript 前端开发
Node 版本控制工具 NVM 的安装和使用(Windows)
本文介绍了NVM(Node Version Manager)的Windows版本——NVM for Windows的安装和使用方法,包括如何安装Node.js的特定版本、列出已安装版本、切换使用不同版本的Node.js,以及其他常用命令,以实现在Windows系统上对Node.js版本的便捷管理。
Node 版本控制工具 NVM 的安装和使用(Windows)