Learn to write website (a) front-end configuration of the installation nvm, node, npm

First, install nvm

node version manager is used to manage a node version of the tool. The main use is to use node npm, can facilitate the management pack some of the front-end development.

nvm installation process (windows):

1. Download

2. Click directly installed

3. Configuration:

① Add the path to the environment variable into nvm.

② Open cmd, and then enter nvm, if there is no prompt command not found, indicating that the installation has been successful.

4. Common Commands

①nvm install node: Install the latest version of node.js. nvm i = nvm install

②nvm install [version]: install the specified version of node.js

③nvm use [version]: use a version of the node

④nvm list: list node which is currently installed version

⑤nvm uninstall [version]: Uninstall the specified version node

⑥nvm node_mirror [url]: Set nvm mirror, the mirror can be used to install internal

⑦nvm npm_mirror [url]: Set npm mirror. Domestic installation image.

Mirror address can also be provided in setting.txt.

You can install multiple versions node, then use to select a version.

Two .node installation

nvm install 6.4.0 version 6.4.0 is installed node

Use nvm after installation, but also the use nvm use 6.4.0 to use.

Three .npm

npm when installing node automatically installed, a node version corresponds to a npm version.

Commonly used commands and usage:

Use Taobao Mirror:

asl install -g cnpm --registry = https: //registry.npm.taobao.org

Since you can use cnpm to install package.

Installation package:

Global Installation: Installation is installed in the current global context node, all items can use this package.

Local Installation: install in the current project (directory), only the current project can be used.

npm isntall express # local installation

npm install express -g # global installation

 

Local installation location

The packages are located ./node_modulesunder (the directory where you run npm command), if there is no node_modulestable of contents, the current execution will npmgenerate a directory command node_modulesdirectory.

It can require()be introduced locally installed package.

module_name = var require(‘module_name')

Such packets will be incorporated as a variable.

Global installation location

  1. The packages are located in /usr/localor under your nodeinstallation directory.
  2. It can be used directly from the command line.

Uninstalling packages:

npm uninstall [package]

Update package:

npm update [package]

Search package:

npm search [package]

 nPM heat

Use npm initcommand to generate a local package.jsonfile, package.jsonis used to record your current project it depends on which package, anyone else after you get the item, do not need your node_modulesfolder (node_moduels package because it is too large). Only need to perform npm installthe command, it will be installed automatically package.jsonunder devDependenciesspecified dependencies.

After using npm init command, and then when the local installation of a new package, just add --save -dev automatically saved in the json file.

Guess you like

Origin www.cnblogs.com/ohahastudy/p/10984263.html