node basics
Briefly: Node.js is JavaScript running on the server. The core of the operation is Google's V8 engine
- Installation: node Chinese network
- View version:
node -v
- Create a js program hello.js input
and then execute in the terminalnode hello.js
- Create application: a node application mainly consists of 2 parts
- This part of the node.js module is imported with require
- An Http service is created with imported modules to listen for client requests
first application
touch app.js
- 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 -v
version
- 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
- Taobao Mirror (cnpm) for Harmony Extranet
- 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
- Other commands:
npm list
npm list -g
模块版本npm list grunt