Node basic concepts and basic usage 1

node basics

Briefly: Node.js is JavaScript running on the server. The core of the operation is Google's V8 engine

and then execute in the terminalnode hello.js

  • Create application: a node application mainly consists of 2 parts
  1. This part of the node.js module is imported with require
  2. An Http service is created with imported modules to listen for client requests

first application

  1. touch app.js
  2. Open app.js and enter the following code

We execute node app.js in the terminal and we can see the returned data on localhost:8888

NPM

npm is a package management tool installed with NodeJSView  npm -vversion

  1. upgrade sudo npm install npm -g

Note: When npm install is executed, package.json and the corresponding node_modules file will be generated in the project, which is the file managed by npm

  1. Taobao Mirror (cnpm) for Harmony Extranet
  1. The difference between -g global installation and local installation: local installation in the project's node_modules, global installation in /usr/local or your node installation directory, if you want to have both functions, you need to install it in two places or use npm link.

Note: Reason for rnpm link in RN: The following components are all natively developed, wrapped with a layer of js, so you need to link .a to the project

  1. Other commands: npm list npm list -g 模块版本npm list grunt

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324836651&siteId=291194637