Linux
UBUNTU EC2 내 초기 express.js 세팅(online)
jjnll
2022. 7. 11. 11:10
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