Some knowledge of node. js

Source: Internet
Author: User
Tags install node npm install node

    • What is node. js
    1. node. JS is a JS operating environment built on the Chrome browser V8 engine
    2. Can parse and execute JS code
    3. You can run the JS code from the browser environment (back end) as a different context, and code parsing is based on the V8 engine
    4. With node. js There are many modules that improve efficiency. That is, node. JS is a running environment and a library
    5. node. JS's event-driven and nonblocking IO Model makes node. JS inherently lightweight and efficient
    • The implementation structure of node. js
    1. V8 JavaScript parsing execution engine ECMAScript
    2. Middle tier (provides file operation, network operation login interface) closer to the operating system interface for developers to use
    3. Hardware layer
    • What node. js can Do
  1. Manipulate files (Create, delete, modify, read)
  2. Provides a Web service (a request that can receive a client in node)
  3. Node can develop some command line tool software
  4. Node can develop dynamic Web sites (feature Web sites with user business interactions)
    • User Login
    • User Registration
    • Add Shopping Cart
    • Display of goods
  5. Node can help us to animate the static page, which was previously written
  6. node. JS does not need to manipulate the DOM, BOM, or write HTML, CSS, and does not need to consider compatibility issues
  7. Node. JS programming is actually writing JavaScript code, which is concerned with business functions
  8. Manipulating persisted data
  9. Can develop command desk tool software
    • The difference between node. js and PHP

Same point:

    1. They all have the ability to manipulate files and have APIs to deal with the underlying operating system.
    2. They are available for network operation, Network Service

Different points:

    1. PHP needs to be combined with Apache to provide Web services.
    2. node. JS abandons all previous servers and node. JS can be used as a server independently
    3. What Java, PHP,. NET can do, node. JS can do it basically, and in some respect it's better than that.
    • Install Package management tool NPM
    1. Allows users to download third-party packages written by others from the NPM server to local use
    2. Allow users to download and install command-line programs written by others from the NPM server to local use
    3. Allow users to upload their own packages or command-line programs to the NPM server for others to use
    • node. JS module load rule, that is: package load

When the module identity is neither a file module nor a core module,

node. JS follows certain rules to find the package module first to find the current Node_modules directory has no toolkit (such as the project Reference Node-markdown package), if any, first find Package.json file, find Package.json After the file, look for the main property inside if the Package.json file does not have or no main property or the file module specified by the main property does not exist, node. JS will fetch the Node_modules directory under the first level directory to find the toolkit to continue the flow above Until you find the root directory, if you do not find the error. Because of the existence of such a rule, the Require file path can be written directly into the file name of the package.

    • In order to prevent accidental deletion of packets, it is not clear that the missing file modules, core modules and so on, this time you need this installation command

NPM Install Node-markdown--save

Then the Package.json file is more "Depandencies": {"Node-markdown": "^0.1.1"},

Delete the package at this time and execute the following command to initialize the Package.json file

NPM init-y

Re-execute

NPM Install Node-markdown--save

Then the package in the file will automatically download the missing package

    • Here's a summary of some NPM common commands

NPM Init "-y" Initializes a Package.json file

NPM Install package name installs a package

NPM Install–save Package names installed packages added to Package.json dependencies (dependencies)

NPM INSTALL–G Package Name Install a command-line tool NPM Docs package name View the documentation for the package "very useful"

NPM root-g View Global Package installation path

NPM config set prefix "path" modifies the global package installation path

NPM List View all packages installed under the current directory

NPM list-g View all packages under the installation path of the global package

NPM Uninstall package name unload a package in the current directory

NPM UNINSTALL–G Package Name Uninstall a package under the global installation path

NPM Update package name updates a package in the current directory

Some knowledge of node. 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.