React๋ Node.js ๊ฐ๋ฐ ํ๊ฒฝ์์๋ ์ฝ๋ ์์ ํ ์๋ ์ฌ์คํ ๊ธฐ๋ฅ์ด ๊ธฐ๋ณธ์ ์ผ๋ก ์ ๊ณต๋์ด ๊ฐ๋ฐ ํจ์จ์ฑ์ ๋์ฌ์ค๋ค. ํนํ Node.js์์๋ nodemon์ด๋ผ๋ ์ ํธ๋ฆฌํฐ๋ฅผ ํตํด ํ์ผ ๋ณ๊ฒฝ์ ๊ฐ์งํ๊ณ ์๋ฒ๋ฅผ ์๋์ผ๋ก ์ฌ์์ํ๋ค.
๋ฐ๋ฉด, Python ๊ฐ๋ฐ ์์๋ ์ฝ๋ ์์ ํ ๋งค๋ฒ ์๋์ผ๋ก ์คํฌ๋ฆฝํธ๋ฅผ ์ข ๋ฃ(ctrl + c)ํ๊ณ ์ฌ์คํํด์ผ ํ๋ ๋ฒ๊ฑฐ๋ก์์ด ์๋ค. ์ด๋ ๊ฐ๋ฐ ์๋๋ฅผ ์ ํ์ํค๊ณ workflow๋ฅผ ๋ฐฉํดํ ์ ์๋ค.
์ด ๊ธ์์๋ Python ๊ฐ๋ฐ ํ๊ฒฝ์์๋ nodemon์ ํ์ฉํ์ฌ ์ฝ๋ ๋ณ๊ฒฝ ์ ์๋์ผ๋ก ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์คํํ๋ ๋ฐฉ๋ฒ์ ์๊ฐํ๋ค.
1๏ธโฃ ํ๋ก์ ํธ ํด๋ ๋ด package.json ํ์ผ ์์ฑ
npm init -y
2๏ธโฃ nodemon ์ค์น
# ์ ์ญ ์ค์น(์์คํ
์ ์ฒด์์ ์ฌ์ฉ ๊ฐ๋ฅ)
npm install nodemon -g
# ๊ฐ๋ฐ ์์กด์ฑ์ผ๋ก ๋ก์ปฌ ์ค์น(ํ์ฌ ํ๋ก์ ํธ์๋ง ์ค์น)
npm install nodemon --save-dev
๐ ์ผ๋ฐ์ ์ผ๋ก --save-dev ์ต์ ์ ์ฌ์ฉํ์ฌ ํ๋ก์ ํธ๋ณ๋ก ์ค์นํ๋ ๊ฒ์ด ๊ถ์ฅ๋๋ค.
3๏ธโฃ package.json ํ์ผ ์์
{
"scripts": {
"dev": "nodemon --exec python test.py"
},
}
scripts ์์ฑ ์์ dev ์์ฑ ์ถ๊ฐ
- nodemon: Node.js ๊ธฐ๋ฐ์ ๋๊ตฌ๋ก, ํ์ผ ๋ณ๊ฒฝ์ ๊ฐ์งํ๊ณ ์๋์ผ๋ก ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์คํ
- --exec: nodemon์๊ฒ ์คํํ ๋ช ๋ น์ด๋ฅผ ์ง์
- python test.py: ์ค์ ๋ก ์คํ๋ ๋ช ๋ น์ด, Python ์ธํฐํ๋ฆฌํฐ๋ฅผ ์ฌ์ฉํ์ฌ test.py ํ์ผ์ ์คํ
๐๐ป ์ฐธ๊ณ ์ฌ์ดํธ
How do i watch python source code files and restart when i save?
When I save a python source code file, I want to re-run the script. Is there a command that works like this (sort of like nodemon for node)?
stackoverflow.com
[NODE] ๐ ๏ธ nodemon ์ค์น & ์ฌ์ฉ ๋ฐฉ๋ฒ ์ ๋ฆฌ
nodemon ๋ชจ๋ Node.js ๊ฐ๋ฐ ์ ์๋ฐ ์คํฌ๋ฆฝํธ ํ์ผ๋ค์ ์์ ํ ๋๋ง๋ค ๋งค๋ฒ ctrl+c๋ฅผ ํตํด node๋ฅผ ์ข ๋ฃ ํ ๋ค์ ์คํํด์ค์ผ ํ๋ ๋ฒ๊ฑฐ๋ก์ ์ด ์์์ต๋๋ค. ํ์ง๋ง ํ์ผ๋ค์ ๋ชจ๋ํฐ๋งํ๊ณ ์๋ค๊ฐ ์์ ๋
inpa.tistory.com
'Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ๋ฐ์ดํฐ ์ ์ถ๋ ฅ ๋ฐฉ๋ฒ (0) | 2024.09.15 |
---|---|
[Python] IDLE can't import Tkinter. Your Python may not be configured for Tk. ์๋ฌ ํด๊ฒฐ (0) | 2024.08.12 |