Home > Web Front-end > Vue.js > How to use npm to download vue.js

How to use npm to download vue.js

藏色散人
Release: 2020-11-30 10:45:12
Original
3123 people have browsed it

How to use npm to download vue.js: First go to the [node.js] official website to download and install the tool; then install bower; then initialize npm; finally pass "npm install vue -- save" to download vue.

How to use npm to download vue.js

Recommended: "vue tutorial"

The operating environment of this tutorial: windows7 system, Vue2.9.6 version, this method is applicable to all brands of computers.

Use npm to download vue:

1. Install npm

1. Install node.js

npm(Node Package Manager): Package manager under node.js

Go to the node.js official website to download and install the tool. After nodejs is installed, npm will be automatically installed. Enter the following command on the command line to test whether it is installed. If successful, the version number will appear correctly.

node -v
npm -v
Copy after login

Look at the other two directories: npm and npm-cache under C:\Users\Administrator\AppData\Roaming. The local warehouse of npm runs in the user directory of the system disk c drive (not seen) to npm-cache because it has not been used and the cache directory is generated as soon as it is used), we tried to move these two directories back to D:\nodejs

2. Change the local library and cache directory

First create 2 new folders in the nodejs directory: node_cache and node_global

Then run the following 2 commands

npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"
Copy after login

Look at npm’s local warehouse, enter the following commands and find that the directory has changed :

npm list -global
Copy after login
Copy after login

3. Configure the download source address

Enter the following command to configure the Taobao mirror station:

npm config set registry=http://registry.npm.taobao.org
Copy after login

Enter the following command to display all configuration information:

npm config list
Copy after login

We pay attention to a configuration file C:\Users\Administrator\.npmrc and find that the information just configured is in this file.

4. Update npm

Update npm:

npm install npm -g
Copy after login

Check what modules are in global again:

npm list -global
Copy after login
Copy after login

5. Add environment variables

Add D:\nodejs\node_global to the environment variable PATH.

2. Download the core library vue.js

1. Install bower

Install bower first: (To install bower, you need to install node.js and git first)

npm insall bower -g
Copy after login

After installation, corresponding commands will be added in the node_global directory.

Check the vue version:

bower info vue
Copy after login

2. Initialize npm

Initialize npm and guide the creation of a package.json file in the project to save the installation package information:

npm init --yes
Copy after login

3. Download vue to local

Enter the project root directory, cnpm install vue --save or -S (cnpm is Taobao npm, if npm changes the download source The address is Taobao source, you can use npm directly instead of cnpm)

npm install vue --save
Copy after login

The above is the detailed content of How to use npm to download vue.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template