Home  >  Article  >  Web Front-end  >  How to install and configure npm

How to install and configure npm

清浅
清浅Original
2019-01-21 17:47:4092018browse

The installation and configuration of npm has the following steps: download and install nodejs, open cmd to check whether the installation is successful, npm environment configuration, check whether npm is configured successfully

npm installation and environment configuration

How to install and configure npm

##[Recommended article: What are some useful tips and tricks in npmWhat is npm

(1) Download and install nodejs

Download address:

https://nodejs.org/en/

How to install and configure npm

Just select next, the path D selected in this article :\nodejs folder

(2) Open CMD and check whether the path is normal

How to install and configure npm

( 3) After the installation is completed, test whether nodejs and npm are successfully installed.

Method: Enter node -v in cmd, npm -v will display the version prompt as shown below, which means the installation of NodeJS and npm is completed.

How to install and configure npm

(4) npm configuration

Module path, cache path

First configure the storage path of npm’s global module And the cache path

Specific method: Create two folders "node_global" and "node_cache" under NodeJs. As shown below

Image 19.jpg

Then run the following 2 commands

npm config set prefix "D:\nodejs\node_global"

npm config set cache "D:\nodejs\node_cache"

How to install and configure npm

You can find that the directory path has changed

Enter the command npm config set registry=http://registry. npm.taobao.org Configure the mirror station

Enter the command npm config list to display all configuration information

How to install and configure npm

Check whether the mirror station is OKCommand 1

npm config get registry

How to install and configure npm

Check whether the mirror station is working. Command 2

Npm info vue See if you can get vue information

How to install and configure npm

Note that at this time, the default module D:\nodejs\node_modules directory

will be changed to the D:\nodejs\node_global\node_modules directory,

If you run npm install and other commands directly, an error will be reported.

We need to do one thing: add the environment variable NODE_PATH. The content is: D:\nodejs\node_global\node_modules,

Add D:\nodejs\node_global

# to the path environment variable.

How to install and configure npm##1. Test NPM installation vue.js

Command: npm install vue -g

The -g here refers to installation to the global global directory

How to install and configure npmWe can find that vue is found in the global directory


How to install and configure npmAt this step our npm Installed and configured

Summary: The above is the entire content of this article, I hope it will be helpful to everyone.

The above is the detailed content of How to install and configure npm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn