Error: listen EADDRINUSE :::3000

错误详细信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

events.js:183

throw er; // Unhandled 'error' event

^



Error: listen EADDRINUSE :::3000

at Server.setupListenHandle [as _listen2] (net.js:1360:14)

at listenInCluster (net.js:1401:12)

at Server.listen (net.js:1485:7)

at Function.listen (E:\VsCode\mock-github-api\node_modules\express\lib\appli cation.js:618:24)

at Object.<anonymous> (E:\VsCode\mock-github-api\index.js:180:5)

at Module._compile (module.js:653:30)

at Object.Module._extensions..js (module.js:664:10)

at Module.load (module.js:566:32)

at tryModuleLoad (module.js:506:12)

at Function.Module._load (module.js:498:3)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! mock-github-api@1.0.0 start: `node index`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the mock-github-api@1.0.0 start script.

npm ERR! This is probably not a problem with npm. There is likely additional log ging output above.



npm ERR! A complete log of this run can be found in:

npm ERR! D:\Program Files\nodejs\node_cache\_logs\2019-03-19T06_44_19_978Z-d ebug.log

express框架之跨域请求

express.js跨域请求代码如下:

1
2
3
4
5
6
7
8
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1')
res.header("Content-Type", "application/json;charset=utf-8");
next();
});

按照上面的代码,即可解决跨域问题。

jQuery和js之Cookie实现

Web开发者的朋友们基本上都知道,jQuery是对js的封装。今天之所以想讲解这个问题,主要是因为Cookie用的还是比较多,应用场景除了老生常谈的购物车,还有就是用户状态(以我之前开发的一个项目除了session和token外,还有一个加密cookie,双重保护,确保系统安全)。