npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead

When installing and configuring node, cmd checks that there is no problem with node

 But checking npm shows:

npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead

 Reason :

The problem arises that the command of the previous version of npm is usually XXX -g but with the version change, this old method is deprecated, at this time

Two files npm and npm.cmd need to be modified.

1. Modify the 23rd line  of the npm file to the style shown below, the command is as follows, you can paste it directly

prefix --location=global

2. Modify line 12 of the  npm.c md file to the style shown in the figure below. The command is as follows, you can paste it directly, and save it after modification.

 

At this point, reopen cmd, npm -v will not report an error (if you still report an error, you can try to restart the computer)

However, when using some common commands of npm, using XXX -g will still report an error. This is because the higher version -g command has been deprecated, so the existing method XXX–location=global should be used

In fact, the content of the error report tells us that npm WARN configures the global '--global', '--local' is deprecated.

Use "--location=global" instead.

 For example: to install common express modules, you should use the following command line

npm install express -g
npm install express --location=global   //安装常用express模块

 Setup is complete.

Guess you like

Origin blog.csdn.net/weixin_54514751/article/details/130536911