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
##[Recommended article: What are some useful tips and tricks in npm、What is npm】
(1) Download and install nodejs
Download address: Just select next, the path D selected in this article :\nodejs folder(2) Open CMD and check whether the path is normal
( 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.(4) npm configuration
Module path, cache pathFirst configure the storage path of npm’s global module And the cache pathSpecific method: Create two folders "node_global" and "node_cache" under NodeJs. As shown below Then run the following 2 commandsnpm config set prefix "D:\nodejs\node_global"npm config set cache "D:\nodejs\node_cache" You can find that the directory path has changedEnter the command npm config set registry=http://registry. npm.taobao.org Configure the mirror stationEnter the command npm config list to display all configuration information Check whether the mirror station is OKCommand 1npm config get registry Check whether the mirror station is working. Command 2Npm info vue See if you can get vue information 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.
##1. Test NPM installation vue.js
Command: npm install vue -g
The -g here refers to installation to the global global directory
We can find that vue is found in the global directory
At 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!