npm#2

How to use someone's code(module) #2 Use as corresponding 'module'

๋ถ€ํ’ˆ์ฒ˜๋Ÿผ ๊ฐ€์ ธ์™€์„œ ์‚ฌ์šฉํ•  npm์„ ์„ค์น˜ํ•˜๊ธฐ ์ด์ „์— ๋จผ์ € ํ”„๋กœ์ ํŠธ ํด๋”๋ฅผ npm์˜ ํŒจํ‚ค์ง€๋กœ ์ดˆ๊ธฐํ™”์‹œ์ผœ์•ผํ•œ๋‹ค.

npm init

1.๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ๋งŒ๋“  ๋ชจ๋“ˆ์„ ๋…๋ฆฝ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ๋•Œ(standalone) ex) uglify - ์ „์—ญ์—(global-g) ์‚ฌ์šฉ

npm install sample -g

-๋กœ์ปฌ์—์„œ ์‚ฌ์šฉ : ํ˜„์žฌ npm์ด ์žˆ๋Š” ๋””๋ ‰ํ† ๋ฆฌ์—์„œ '๋ถ€ํ’ˆ์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์ผ์‹œ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ๋•Œ ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.(extraneous;๊ด€๋ จ์—†๋Š”)

npm install sample
npm install underscore

2.๋‹ค๋ฅธ ์‚ฌ๋žŒ์ด ๋งŒ๋“  ๋ชจ๋“ˆ์„ ๋‚ด sw์— ํฌํ•จ์‹œํ‚ฌ ๋•Œ : ์™ธ๋ถ€๊ฐ€ ์•„๋‹ˆ๋ผ ์•„์˜ˆ ์ข…์†์‹œ์ผœ๋ฒ„๋ฆฐ๋‹ค. ์ด ํ”„๋กœ์ ํŠธ์— ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•˜๊ณ , ํ•ญ์ƒ ๊ฐ™์ด ๋‹ค๋…€์•ผํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. "dependincies"ํ•ญ๋ชฉ์ด ์ถ”๊ฐ€๋˜๋ฉฐ ์ข…์†์„ฑ์ด ๋ช…์‹œ๋œ๋‹ค. ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ์—์„œ ์ข…์†์„ฑ์ด ์žˆ๋Š” ํŒจํ‚ค์ง€๋ฅผ ์‰ฝ๊ฒŒ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

npm install underscore --save

ํ˜„์žฌ ๋‚˜์˜ swํŒจํ‚ค์ง€๋Š” underscore์— ์˜์กดํ•˜๊ณ  ์žˆ๋‹ค. "dependincies"๊ฐ€ ์žˆ์œผ๋ฉด package.json ํŒŒ์ผ๋งŒ ์žˆ์œผ๋ฉด ์–ธ์ œ๋“  ์ž์‹ ์˜ ํŒจํ‚ค์ง€์— underscore 1.12.0์„ ํฌํ•จ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค๋Š” ๋œป์ด๋‹ค.

"dependencies": {
    "underscore": "^1.12.0"
  }

Last updated