UBUNTU EC2 내 초기 express.js 세팅(online)
2022. 7. 11. 11:10ㆍLinux
1. node.js, npm 설치
* https://rpm.nodesource.com/setup_14.x - Node.js v14 LTS "Fermium" (recommended)
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
app-get 이용하여 node.js 설치
sudo apt-get install -y nodejs

app-get update
설치된 버전 확인
node -v
npm -v
npm 통해 yarn 설치
sudo npm install --global yarn
yarn init으로 package.json 생성
yarn init
ubuntu@ip-***-**-**-***:~/app$ sudo yarn init
yarn init v1.22.19
question name (app):
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
question private:
success Saved package.json
>> 해당 question에 값 지정 가능, blank시 default값 입력(괄호 내 값)
>> yarn init이 대체 뭐길래?? (더 ++)
mkdir app
touch app.js
vi app.js
in app.js
const express = require("express");
const app = express();
const port = 3000;
app.get("/", (req, res) => {
res.send("Hello World!");
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
:wq
node app.js

728x90
'Linux' 카테고리의 다른 글
The package-lock.json file was created with an old version of npm, (0) | 2022.07.21 |
---|---|
~은 (는) sudoers 설정 파일에 없습니다. 이 시도를 보고합니다. (0) | 2022.07.20 |
linux tar 파일 압축 및 해제 (0) | 2022.07.20 |
CentOS7 EC2 MariaDB 설치 및 삭제(online) (0) | 2022.07.18 |
UBUNTU EC2 내 MongoDB 설치(online) (0) | 2022.07.12 |