NPM Installation Tutorial (vue.js)

Source: Internet
Author: User

Https://www.cnblogs.com/goldlong/p/8027997.html

First clarify the relationship between Nodejs and NPM:

node. JS is a running environment for JavaScript and is an encapsulation of the Google V8 engine. is a server-side JavaScript interpreter.

Include the relationship, Nodejs contains NPM, for example, you install the Nodejs, you open the cmd input npm-v will find out the line NPM version number, stating that NPM has been installed.

Quote from the Great God Summary:

In fact, NPM is Nodejs's package manager. When we develop in node. js, we use a lot of JavaScript code that someone else has written, and if we need someone else's code, we can search for it by name, download the source, unzip it, and use it, it will be very troublesome. So there is the guarantee manager NPM. Everyone to write their own source code to the NPM online, if you want to use some or some, directly through the NPM installation can be, do not care where the source code. And if we are going to use module A and module A is dependent on module B and Module B is dependent on modules C and D, NPM will download and manage all dependent packages based on dependencies. Imagine how troublesome it would be to do all this work on our own!

Node-v View the node version with the built-in NPM Package Manager to install the dependency package.

NPM install-g typescript



First, before using, we have to Master 3 things is used for what. The package Manager under Npm:nodejs. Webpack: Its main purpose is to prepare the static resources that all browsers need to publish through the COMMONJS syntax, such as the merging and packaging of resources. VUE-CLI: User generated Vue project template. (To help you quickly start a Vue project, that is, to give you a VUE structure, including the base of the dependent library, only need NPM install can be installed)

Begin:

, download 8.9.3 LTS (recommended for use by most users)

Double-click Install

You can use the default path, which in this example modifies itself to D:\nodejs

All the way next.

Point Finish Finish

Open cmd to check for normal

Looking at the other 2 directories, NPM's local repository ran in the user directory of the system disk C drive (not seen Npm-cache because it was not used, a cache directory was generated), we tried to move these 2 directories back to D:\nodejs first as 2 directories and then run the following 2 commands NPM Config set prefix "D:\nodejs\node_global" npm config set cache "D:\nodejs\node_cache" for example, let's look at NPM's local repository and enter the command NPM list- Global

Input command NPM config set registry=http://registry.npm.taobao.org Configure mirror Station

Input Command NPM config list displays all configuration information, we are concerned about a configuration file C:\USERS\ADMINISTRATOR\.NPMRC

Edit it with a text editor and see the configuration information you just made

Check the mirror station line. Command 1NPM config get registry

Check the mirror station line. Command 2NPM info vue to see if you can get Vue's information.

Note that at this point, the default module D:\nodejs\node_modules directory will be changed to the D:\nodejs\node_global\node_modules directory, if the direct run NPM Install command will be error. We need to do 1 things: 1, increase the environment variable Node_path content is: D:\nodejs\node_global\node_modules

(Note that the operation needs to reopen CMD for the above environment variable to take effect) I. Test NPM installation vue.js command: NPM install vue-g Here the-G means to install to the global directory

Ii. Test NPM Installation vue-router command: NPM install Vue-router-g

Running NPM install vue-cli-g installing VUE Scaffolding

Edit Environment Edit Path

Add the following version of the PATH environment variable D:\NODEJS\NODE_GLOBALWIN10, the horizontal display path, note to add to the end, do not have a semicolon ";"

Reopen cmd and test that the Vue is using normal

Note that the VUE-CLI tool is built-in with templates including Webpack and Webpack-simple, which are more complex and professional projects, and his configuration is not entirely placed in the root directory of webpack.config.js.

Initialize, install dependent

Run NPM Install dependencies

NPM Run Dev

Successful interface, prompt to open address http://localhost:8080

Automatically open browser http://localhost:8080/#/

NPM run build generates a static file and opens a newly generated index.html file under the Dist folder

The list of new VUE01 under NMP is described:

NPM Installation Tutorial (vue.js)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.