SW

11일차. nodejs에서 package 관리하기

S.Zinlee 2015. 11. 28. 00:26

지난 시간에 node server에서 rpi-temp-module를 설치하여 사용하는 방법에 대해 알아 보았다.


이제 앞으로 좀 더 많은 살을 붙여 나가면서 더 많은 package를 설치하게 될텐데

이를 좀 더 효율적으로 관리하기 위해 npm에서 제공하는 기능을 통해 package를 관리하도록 해보자.


pi@raspberrypi ~/server/was $ npm init
 This utility will walk you through creating a package.json file.
 It only covers the most common items, and tries to guess sane defaults.

 See `npm help json` for definitive documentation on these fields
 and exactly what they do.

 Use `npm install <pkg> --save` afterwards to install a package and
 save it as a dependency in the package.json file.

 Press ^C at any time to quit.
 name: (was) rpi_was
 version: (1.0.0) 1.0.0
 description: fish box management system
 entry point: (index.js) index.js
 test command:
 git repository:
 keywords:
 author: szinlee
 license: (ISC)
 About to write to /home/pi/server/was/package.json:

 {
    "name": "rpi_was",
    "version": "1.0.0",
    "description": "fish box management system",
    "main": "index.js",
    "dependencies": {
      "rpi-temp-module": "^1.0.0"
    },
    "devDependencies": {},
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "szinlee",
    "license": "ISC"
  }


 Is this ok? (yes) yes


설정을 완료 하면 package.json 파일이 생성된 것을 확인할 수 있다.

해당 파일을 열어 보면 우리가 지난 시간에 추가했던 모듈이 dependencies안에 위치한 것을 확인할 수 있다.

설치 버전은 1.0.0이다.


앞으로는 이 파일에 모듈을 추가해 가면서 작업을 진행할 것이다.