Nodejs
What is nodejs
- Based on the operating environment ChromeV8 runtime JavaScript
- event-Driven Event Driven
- Non-blocking i / o high concurrency-friendly
- Package management tool npm (nodePakageManager) current understanding similar to that warehouse maven package? ? ?
- nvm nodeVersionManager version of the controller
js operating environment:
- Browser
- The basic syntax section
- good
- judgment
- ajax
installation:
Installation nodejs environment
npm install:
- temporary use:
$ npm install express --registry https://registry.npm.taobao.org
//用国内的镜像就可以了 外头的太慢
- Global Use
$ npm config set registry https://registry.npm.taobao.org
//接下来验证是否成功↓↓↓
$ npm info express
$ npm -v
My success story:
adam@ MINGW64 ~/Desktop/nodejs
$ npm -v
6.13.4
The node operating environment REPL
adam@▒▒▒▒▒▒▒ MINGW64 ~/Desktop/nodejs
$ node
Welcome to Node.js v12.16.1.
Type ".help" for more information.
> 1+1
2
>
(So-called repl bluntly, that is to write a script function directly in the window .. bash was feeling nothing great use ..
Do a little exercise with nodejs from a server
$ touch nodejsServerTest.js
$ vi nodejsServerTest.js
$ node nodejsSeverTest.js
// nodejsSeverTest.js的代码如下
var http = require("http")
http.createServer(function (request , response){
// send header of http
// http status value: 200
// pageType : text/plain
response.writeHead(200,{'content-Type' : 'text/plain'})
// send response message :
response.end('hello nodejs');
}).listen(8888);
console.log('server is running at 127.0.0.1:8888');
adam@ MINGW64 ~/Desktop/nodejs
$ node nodejsServerTest.js
server is running at 127.0.0.1:8888
附1
api documentation:
This is the back-end necessary work. The rear end of the various parameters required to write and attach explanation url to a front end (which is an interface). The entire project, or a collection of url and description of part of their own responsibility, this is the interface documentation.
View Document Interface api example
附2
nodejs seamless handover version
View all versions of your current version / owned
nvm -v / nvm ls (也可使用 node -v 查看当前版本)
Use a version
nvm use v10.xx.xx
附3
Server Status value
- 200: ok indicates that the server running, normal access
- 301 Moved Permanently 301 permanent redirect redirect
- Http / 1.1 400 Bad Request error binding domain
- Http / 1.1 403 Forbidden does not have access to this station
- Http / 1.1 404 Not Found file or directory does not exist
- Http / 1.1 500 Internal Server Error or server error