Skip to content

Instantly share code, notes, and snippets.

@minhoryang
Forked from AilisObrian/0.README.md
Last active September 29, 2018 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minhoryang/41832b2a613ab95df0a96aff7a67e34f to your computer and use it in GitHub Desktop.
Save minhoryang/41832b2a613ab95df0a96aff7a67e34f to your computer and use it in GitHub Desktop.
Node.JS 개발 환경 구성!

최신 Node.js 설치 및 사용

  • $로 시작하는 줄은, 한줄 한줄 복사해서 터미널에서 실행해주셔야합니다.
  • 터미널을 재시작 하여야 할 수도 있습니다.
    • 재시작 후, 현재 작업하는 폴더로 다시 이동해주셔야합니다.

1. anyenv 설치

$ git clone https://github.com/riywo/anyenv ~/.anyenv
$ echo 'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(anyenv init -)"' >> ~/.bash_profile

(주의) 터미널에서 위의 명령을 실행 후, 터미널을 끄고 다시 킵니다.

2. ndenv 설치

$ anyenv install ndenv

(주의) 터미널에서 위의 명령을 실행 후, 터미널을 끄고 다시 킵니다.

3. node 설치

$ ndenv install v6.2.0

(주의) 터미널에서 위의 명령을 실행 후, 터미널을 끄고 다시 킵니다.

4. 현재 폴더에서 설치 확인

  • $ cat .node-version
    • v6.2.0
      • 우리는 이 폴더에서는 Node v6.2.0을 사용하기로 하였습니다.
  • $ node --version
    • v6.2.0
      • 여기에 저희가 설치한 Node의 버전이 나와야합니다.
  • $ npm | tail -1
    • npm@3.8.6 /Users/_/.anyenv/envs/ndenv/versions/v6.2.0/lib/node_modules/npm
      • 여기에 저희가 설치한 node의 버전이 경로의 중앙에 나와야합니다.

(알림) 다른 폴더에서도 특정 노드의 버전을 사용하고 싶을 경우, $ ndenv local v6.2.0 를 사용해야 합니다.

프로젝트 환경변수 적용

이 프로젝트에서 사용하는 환경변수는 .env파일에 보관되어 있습니다. autoenv는 이를 자동으로 불러와 줍니다.

1. autoenv 설치

$ git clone git://github.com/kennethreitz/autoenv.git ~/.autoenv
$ echo 'source ~/.autoenv/activate.sh' >> ~/.bash_profile

(brew로도 설치할 수 있습니다.)

(주의) 터미널에서 위의 명령을 실행 후, 터미널을 끄고 다시 킵니다.

2. bc1 폴더로 들어갈 때, 다음과 같은 확인 메세지가 뜨며,

autoenv:
autoenv: WARNING:
autoenv: This is the first time you are about to source /Users/_/projects/node_workspace/bc1/.env:
autoenv:
autoenv:     --- (begin contents) ---------------------------------------
autoenv:     if [[ ! -d $PROJECT_PATH_BC1 ]]; then$
autoenv:         export PROJECT_PATH_BC1="`pwd`"$
autoenv:         export NODE_PATH="$PROJECT_PATH_BC1/node_modules"$
autoenv:         export PATH="$NODE_PATH/.bin:$PATH"$
autoenv:     fi$
autoenv:
autoenv:     --- (end contents) -----------------------------------------
autoenv:
autoenv: Are you sure you want to allow this? (y/N)

3. y를 입력하여 넘어갑니다.

4. 환경변수가 적용되었습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment