[Node.js] NPM ๋ชจ๋
//Locally
npm install slugify : url์์ /?id=1 ์ธ์ /fresh-avocados : ํน๋ณํ url์ด๋ฆ์ ์์ฑํ๊ฒ ํด์ค
const slugify = require('slugify');
const slugs = dataObj.map(el => slugify(el.productName, { lower: true }));
console.log(slugs)
console.log(slugify('Fresh Avocados', { lower: true }));
npm install nodemon --save-dev : server๋ฅผ ๋งค๋ฒ ํค๊ฑฐ๋ ๋๊ฑฐ๋ ํ์ง ์๊ฒ ํด์ค๋ค.
//Globally
npm i nodemon --global
mac : sudo npm i nodemon --global
์๋ฒ ์์
ํญ์ ์๋ฒ๋ฅผ ํฌ๋, node [ํ์ผ๋ช ] , exit , ๋ค์ ์๋ฒ ํค๊ธฐ ๋ฐ๋ณตํด์ผํ๋ค
nodemon [ํ์ผ๋ช ] --> ํ์ผ์ ๋ณ๊ฒฝ์ด ์๊ธธ๋๋ง๋ค, ์๋ฒ๋ฅผ ์๋ํด์ค๋ค.
์ด๋ ๊ฒ package.json์ ์์ฑํด์ฃผ๋ฉด
nodemon index.js๋ฅผ ํฐ๋ฏธ๋์ ๊ณ์ ์์ฑํด์คํ์๊ฐ ์์ด
npm (run) start์ด๋ ๊ฒ ํ๋ฉด ๋ฐ๋ก ์๋ฒ๊ฐ ์๋๋จ
//Package Versioning and Updating
2/0/16
mainVersion/MinorVersion/PatchVersion
mainVersion : new features on main with breaking previous version , affects the code in the previous version
minorVersion : new features on minor version with no breaking changes
PatchVersion : ๋ฒ๊ทธ ์์
npm update
npm outdated : npm ์ต์ ์ผ๋ก ์ ๋ฐ์ดํธ
npm install [slugify@1.0.0] ํน์ ๋ฒ์ ๋ค์ด๋ก๋
์์ ~ ๋ถ์ด๋ฉด, minor version update๋ฅผ ํ์ฉํ์ง ์์ (more safer)
^ ๋ถ์ด๋ฉด, ๋ชจ๋ ๊ฒ์ด ๊ฐ์ฅ ์ต์ ๋ฒ์ ์ผ๋ก
* ๋ถ์ด๋ฉด, ๋ชจ๋ ๋ฒ์ ์ ๋ค์ด๋ก๋ํจ
npm update slugify
npm uninstall [๋ชจ๋์ด๋ฆ] : ๋ชจ๋ ์ญ์