λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
Second Brain/Node

package.json 생성 - npm init λͺ…λ Ήμ–΄

by 솑두뢀 2022. 5. 23.
728x90
λ°˜μ‘ν˜•

 πŸŽ― npm package μ„€μΉ˜ λ° μ‚¬μš©λ²•πŸŽ―

npm으둜 λ‹€λ₯Έ μ‚¬λžŒλ“€μ΄ λ§Œλ“€μ–΄ λ‘” νŒ¨ν‚€μ§€ μ„€μΉ˜ 및 μ‚¬μš©

NPM (Node Package Manager)

  • μ˜€ν”ˆ μ†ŒμŠ€ κ°œλ°œμžλ“€μ΄ λ§Œλ“  80만개의 μ½”λ“œ νŒ¨ν‚€μ§€κ°€ ν¬ν•¨λ˜μ–΄μžˆλ‹€.
  • μ†Œν”„νŠΈμ›¨μ–΄ 곡유λ₯Ό μœ„ν•΄ npm을 μ‚¬μš©ν•œλ‹€.
  • λͺ¨λ“  npm νŒ¨ν‚€μ§€λŠ” package.jsonμ΄λΌλŠ” 파일둜 μ •μ˜λœλ‹€.
  • node.js μ„€μΉ˜κ°€ μš°μ„ μ μœΌλ‘œ μ΄λ€„μ Έμ•Όν•œλ‹€.

node μ„€μΉ˜


package.json 생성

ν”„λ‘œμ νŠΈμ— λŒ€ν•œ κ°„λ‹¨ν•œ μ„€λͺ…이 λ‹΄κΈ°λŠ” package.json νŒŒμΌμ„ μ •μ˜ν•œλ‹€.

 

- (1) npm init :  각각 μ˜΅μ…˜λ“€μ„ 집적 μž‘μ„±ν•œλ‹€.

'

- (2) npm init -y : λͺ¨λ“  μ˜΅μ…˜μ΄ yes

(1) 과정이 λ²ˆκ±°λ‘­λ‹€κ³  λŠκ»΄μ§„λ‹€λ©΄

npm init -yλͺ…λ Ήμ–΄λ‘œ package.json νŒŒμΌμ„ λ§Œλ“€μ–΄ μ£Όλ©΄ λœλ‹€.

 

 


 

express / uuid4 μ›Ή ν”„λ ˆμž„μ›Œν¬ λ‹€μš΄λ‘œλ“œ

1️⃣ npm install <νŒ¨ν‚€μ§€λͺ…>

uuid4 package download

2️⃣ λͺ…λ Ήμ–΄λ₯Ό μž‘μ„±ν•˜λ©΄ node_modules 폴더가 μƒμ„±λœλ‹€.

 


πŸ”— npm 곡식 μ‚¬μ΄νŠΈ

https://www.npmjs.com/

 

npm

Bring the best of open source to you, your team, and your company Relied upon by more than 11 million developers worldwide, npm is committed to making JavaScript development elegant, productive, and safe. The free npm Registry has become the center of Java

www.npmjs.com

πŸ”— uuid4 package

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

 

uuid4

Node UUID v4 Generator. Latest version: 2.0.2, last published: 2 years ago. Start using uuid4 in your project by running `npm i uuid4`. There are 175 other projects in the npm registry using uuid4.

www.npmjs.com

: npm 곡식 μ‚¬μ΄νŠΈμ—μ„œ νŒ¨ν‚€μ§€λͺ…을 κ²€μƒ‰ν•΄μ„œ μ„€μΉ˜ 및 μ‚¬μš© 방법을 읡힐 수 μžˆλ‹€.

 

uuid4 package Usage

uuid4 νŒ¨ν‚€μ§€ μ‚¬μš©ν•˜κΈ°

1
2
3
// uniqueν•œ ν‚€λ₯Ό μ°λŠ” uuid4 package
const uuid4 = require('uuid4');
console.log((uuid4()));
cs

μ‹€ν–‰

- require μ˜ˆμ•½μ–΄ : JSμ—μ„œ νŒ¨ν‚€μ§€λ‚˜ λͺ¨λ“ˆμ„ μ°Έμ‘°ν• λ•Œ μ‚¬μš© 
'λͺ¨λ“ˆμ„ κ°€μ Έμ™€μ„œ μ‚¬μš©ν•œλ‹€.'
- require('uuid4') : 경둜λ₯Ό μ§€μ •ν•˜μ§€ μ•ŠλŠ”λ‹€. 
: λ‚΄κ°€ λ§Œλ“  것은 .을 찍어가며 μ£Όμ†Œλ₯Ό μ°Ύμ•„κ°€μ•Όν•˜μ§€λ§Œ
남이 λ§Œλ“  λ‚΄μž₯ λͺ¨λ“ˆ 같은 것듀은 경둜λ₯Ό μ§€μ •ν•˜μ§€ μ•Šμ•„λ„ λœλ‹€.
node_modules 폴더가 μ‘΄μž¬ν•˜κΈ° λ•Œλ¬Έμ— λ³€μˆ˜μ²˜λŸΌ λΆˆλŸ¬μ„œ μ‚¬μš©ν•  수 μžˆλ‹€.

 

728x90
λ°˜μ‘ν˜•

λŒ“κΈ€