8000 포트가 실행중인지 확인

cmd  > netstat -ano | findstr :8000

없으면 아무것도 안나온다.

 

8080 포트 실행중인지 확인

cmd  > netstat -ano | findstr :8080

 

 

포트 죽이고 싶을때는

taskkill /f /pid pid번호

ex) 8080 은 9692 이므로 taskkill /f /pid 9692

 

이런 오류가 날땐 아래와 같이 해결하면 된다.

 

 

 

 

 

 

 

window > 환경 변수 편집

 

 

 

 

 

 

 

 

 

 

고급 > 환경 변수

 

 

 

 

 

 

 

 

 

 

시스템 변수 > Path > 편집

 

 

 

 

 

 

 

 

 

 

 

 

 

새로 만들기 > MySQL가 설치된 bin 의 폴더 추가 후 확인 클릭

설치 시 따로 건들지 않았다면 Program Files 하위 디렉토리에 있다.

 

 

모두 저장 후 cmd 창도 껐다 다시 열기

 

 

 

이제 잘된다!

 

 

 

 

 

 

'공부 > My SQL' 카테고리의 다른 글

oracle 하루 이전 날짜 구하기  (0) 2022.05.25
oracle json value 추출  (0) 2022.05.12
WITH AS (CTE)  (0) 2021.03.08
Select Create Table, Insert Ignore INTO.., ON DUPLICATE KEY  (0) 2021.03.02
뷰, 스토어드 프로시저, 트리거  (0) 2020.12.12

1. node.js 설치

 

https://nodejs.org/ko/download/

 

다운로드 | Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

nodejs.org

위 링크 이동 Node.js 다운로드 받는다.

현재 버전은 버그가 있을 있으니 LTS 클릭 다운로드 하도록 한다.

각자 OS 맞는 것으로 설치한다.

 

 

 

 

 

 

cmd 실행 후 node -v 입력 후 엔터, 버전이 정상적으로 나오면 설치가 된 것이다.

node -v

 

 

 

 

 

 

2. visual studio code 설치

 

https://code.visualstudio.com/Download/

 

Download Visual Studio Code - Mac, Linux, Windows

Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.

code.visualstudio.com

위 링크로 이동 후 vscode 를 설치한다.

 

 

 

 

 

3. 프로젝트 생성

원하는 위치에 마우스 우클릭 > 새로만들기 > 폴더 생성

 

 

 

 

 

 

 

 

 

 

 

 

 

vscode 실행 후  Open Folder >  방금 생성한 폴더를 열어준다.

 

 

 

 

 

 

 

 

 

 

Terminal > New Terminal 클릭 명령어를 입력할 있는 창을 띄워준다.

 

 

 

 

 

다음의 명령어들을 입력해준다.

 

1.   npm install express-generator -g

터미널에 명령어를 입력해서 npm 이용한 express 설치한다.

 

2.   express server

express 기반 프로젝트명이 server  node.js 프로젝트를 생성한다.

 

3.   cd server

2에서 만든 프로젝트 디렉터리로 이동한다.

 

4.   npm start

위 명령어로 프로젝트를 실행시킨다.

 

 

 

 

 

 

 

 

 

 

프로젝트 구조

 

 

 

 

실행된 모습

 

 

 

 

 

App.js

더보기
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
var createError = require('http-errors');
const PORT = process.env.port || 8000;
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
 
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
 
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine''jade');
 
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
 
app.use('/', indexRouter);
app.use('/users', usersRouter);
 
// catch 404 and forward to error handler
app.use(function(req, res, next) {
  next(createError(404));
});
 
// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env'=== 'development' ? err : {};
 
  // render the error page
  res.status(err.status || 500);
  res.render('error');
});
app.listen(PORT, () => {
  console.log(`running on port ${PORT}`);
});
module.exports = app;
 
 
cs

'공부 > Node.js' 카테고리의 다른 글

axios response cookie 설정  (0) 2023.02.02
axios request cookie 설정  (0) 2023.02.02

https://www.npmjs.com/package/cookie

 

cookie

HTTP server cookie parsing and serialization. Latest version: 0.5.0, last published: 10 months ago. Start using cookie in your project by running `npm i cookie`. There are 3494 other projects in the npm registry using cookie.

www.npmjs.com

쿠키 사용하기 위해

$ npm install cookie

명령어 이용해서 설치.

 

 

 

쿠키 사용 위해 react 코드 맨 위에 

var cookie = require('cookie');

선언해주기.

 

 

 

 

 

 

 

 

 

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
const getLogin = (req, res) => {
  axios
    .post("url"null, {
      params: { name1: "value1", name2: "value2", name3: "name3", ....},
    })
    .then((response) => {
      res.cookie('SESSION', response.data.sessionId, {domain : 'localhost', path:'/', httpOnly : true, session : true});
      res.cookie('abcd', response.data.sessionId, {domain : 'localhost', path:'/', httpOnly : true, session : true});
    
    });
};
 
cs

res => 응답

res.cookie 로 쿠키 세팅.

 

 

 

 

 

 

 

 

▲ 쿠키 생김

 

 

 

 

 

 

 

 

 

 

 

https://chrome.google.com/webstore/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm

 

Cookie-Editor

Simple yet powerful Cookie Editor that allow you to quickly create, edit and delete cookies without leaving your tab.

chrome.google.com

chrome  에서 쿠키 보려면 쿠키에디터 설치하면 된다.

'공부 > Node.js' 카테고리의 다른 글

node.js 프로젝트 생성  (0) 2023.02.06
axios request cookie 설정  (0) 2023.02.02

+ Recent posts