当前位置:网站首页>Install nodejs

Install nodejs

2022-08-11 10:33:00 The future is very long, don't just look at the present

This blog is just to record my own installationnodejs的一个过程,Use it for your own convenience later.

目录

傻瓜式安装

Configure environment variables and resolvenpm WARN config global --global, --local are deprecated. Use `--location 警告

 Modify the global download path

 Replace the global download mirror


傻瓜式安装

1、去官网下载 | Node.js 中文网 (nodejs.cn)下载相关的安装包

如果对nodeconfiguration is not required,Actually download this.msiThen do a fool-proof installation,一直下一步(The most is to modify the installation path),Nothing else needs to be modified,这样安装的node也是可以使用的,The only downside is that the location of the instructions or plugins you install yourself in the future is hard to find.This default installation may also be reportednpm WARN config global --global, --local are deprecated. Use `--location .这个只是一个警告,In fact, it will not affect the execution of the program,However, related solutions will be provided later.

Configure environment variables and resolvenpm WARN config global --global, --local are deprecated. Use `--location 警告

2、安装成功以后使用cmdCheck the installed version number(注意:nodejs是默认集成了npmSo we don't need to install it separately)

node -v  //查询node版本
npm -v   //查询npm版本

如果出现:node‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件.Indicates that the environment variable has not been configured. (In fact, this will help us configure the default environment variables during installation)

选择自己node安装的路径,在系统变量中的pathCreate a new variable in ,然后把刚刚复制的nodeCopy the installation path.

比如我的node安装在:E:\nodejs

Then use it in any file pathcmd,然后使用命令 node -v ;

如果没有安装yarn,Use this command to install:npm install --global yarn

(安装这个yarn的时候一定要【Open this with administrator privilegescmd】,否则会出现下面的情况:)

如果在使用cmd查询node版本号的时候,出现npm WARN config global --global, --local are deprecated. Use `--location,Then you need to go to the configuration file to modify the relevant configuration;  

Make changes to the open file:Modify the location specified below as shown in the image below:

prefix --location=global

 

 

如果还是出现:npm WARN config global --global, --local are deprecated. Use --location=global instead.

You can try the following waynpm进行更新.

1、以管理员身份运行,执行命令 set-ExecutionPolicy RemoteSigned

2、选择 y

3、然后执行 npm-windows-upgrade

4、然后选择合适的版本,点击回车.

Then execute the command to view the version.  

 

 Modify the global download path

3、配置环境变量(上面配置了node的)And modify the global module download path

①配置node_global和node_cache

Put the path and cache path of all modules in the futurenodejs安装的文件夹中,Create two under the installation path空文件夹【node_global】和【node_cache】(Of course, it can also not be placed in the installation path,How to find yourself,then how to put it):

以管理员身份打开命令行界面,输入下面命令,  

npm config set prefix "刚刚创建的node_global路径"
npm config set cache "刚刚创建的node_cache路径"

比如我的node_global是在E:\nodejs\node_global,So the command I execute is :npm config set prefix "E:\nodejs\node_global"

比如我的node_global是在E:\nodejs\node_cache,So the command I execute is :npm config set cache"E:\nodejs\node_cache"

②配置node_global和node_cache的环境变量 

在【系统变量】下新建【NODE_PATH】:

在【系统变量】下的【Path】新建node_global的环境变量配置,配置完成后记得点击确定.

 完成上面的配置,We'll download stuff later,nodeThe downloaded file or installation package will arrive at what we just configurednode_glaobal文件下;

npm install express -g     //Remember that the naming window is opened with administrator privileges,Otherwise, permission problems may occur and the operation fails,-g是全局安装的意思,不加-g就是默认下载到当前目录

 

Replace the global download mirror

4、Replace the global download mirror

  • ①Use named to query your own mirror:

npm config get registry  
  • ②更换镜像为淘宝镜像

npm config set registry https://registry.npm.taobao.org/

If the above command is executed no other instructions appear,That is no problem.

You can directly query whether the configuration is successful: npm config get registry

 ③全局安装基于淘宝源的cnpm(比npm快)

npm install -g cnpm --registry=https://registry.npm.taobao.org

执行命令查看cnpm是否安装成功: cnpm -v

如图所示表示安装成功:

 

原网站

版权声明
本文为[The future is very long, don't just look at the present]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208111027020186.html