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

How to use npm to download vue.js

藏色散人
藏色散人Original
2020-11-23 11:36:393160browse

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

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"

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

npm list -global

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

Enter the following command to display all configuration information:

npm config list

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

Check what modules are in global again:

npm list -global

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

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

Check the vue version:

bower info vue

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

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

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!

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
Previous article:What is vue.js mixin?Next article:What is vue.js mixin?