First met node

  Recently I learned some basic knowledge of node, and summarized it a little bit.

First, install node.js

  To install node, just go to node's official website to download the desired version for installation. When installing, record the current installation path,

Because some computers have no environment variables after installation, manual configuration is required;

  Manually configure environment variables: this computer-> properties-> advanced system settings-> environment settings-> double-click Path-> add the current path to path

Second, the node instruction

  CMD tool

    Open CMD:

      1. Enter cmd in the search bar to open cmd 

      2. win + r: call up the running function, enter cmd and press enter

      3. Open in the folder path, enter cmd in the navigation bar, press Enter, and open cmd in the current path

  Test the successful installation of node.js: input: node -v on the command line, and the current node version will be output if successful

  DOS command: cls to clear the screen, ctrl + c + c to force close

Three, node.js preparation

  Open cmd under the corresponding folder

Four, modular

  Introduce the module: require

  Define the module: module.exports = {}

  Module classification: 1, custom module

         2. Built-in module, API is set on one object

         3. Tripartite module 

Five, npm

Dependency management tool:
  1. Create a dependency configuration details (user manual)
  2. Automatically configure according to the dependency manual;
  3. Install third-party plug-ins; web third-party plug-ins can be introduced using CDN, nodejs will download third-party dependencies to the local;
  4. Uninstall third-party plug-ins;
differentiate the installation environment:
  1. Local installation (available in the current folder)
  2. Global installation (available in any location)

npm command

  Explanation of terms: package: the superior package of the module;

    npm init [-y] Create package manual
    npm run command name can run the custom command defined in the scripts in package.json;
    npm install package name package installation environment [-g global environment--save-dev development environment default Is the local environment]

  Goal: Install a third-party package; the
    download site comes from abroad and the download speed is limited.
    The mirror source can be used, and the speed will be greatly improved.

Six, nrm source change tool

1. Installation instructions: `npm install nrm -g` is installed globally;
2. Check the global installation location;

3. Change source

  View available sources: nrm ls
  speed test of available sources: nrm test source name cnpm taobao
  switch source: nrm use source name

Seven, nodemon-node.js hot start tool

Hot start: automatically monitor the js file, and execute it automatically when the file is changed;

  1. Installation instructions: `npm install nodemon -g` global installation;
  2. Hot start test;

Eight, gulp-engineering tools

1. Download gulp local installation: `npm install gulp --save-dev`
  among a plurality observe what file => the node_modules
  observed package.json which a plurality Han => Development Environment dependency devDependencies
2. Download partial gulp -cli installation: `npm install gulp-cli -g`

3. Use the gulp command; test whether gulp is available;

  `gulp -v`

Successful results should show:

CLI version: 2.2.0
Local version: 4.0.2

 

 

Guess you like

Origin www.cnblogs.com/mz33/p/12684389.html