Hyperledger composer 개발 환경 설정 중 발생한 에러들 정리

Yeoman 설치

1
$ npm install -g yo

1. global installation을 위한 NPM default directory 생성

우선 Permission 문제에 대한 문서 NPM docs - getting-started - fixing-npm-permissions 를 참고하여 npm의 Default Directory를 수정한다.

  1. global installation을 위한 디렉토리 생성
1
$ mkdir ~/.npm-global
  1. 디렉토리 경로를 npm config에 세팅
1
2
$ npm config set prefix '~/.npm-global'
$ npm config get prefix # config prefix 세팅이 잘 되었는지 확인
  1. 환경변수 설정
1
$ vi ~/.profile # .profile 수정(사용하는 에디터에 따라 명령어가 다를 수 있다)
1
$ export PATH=~/.npm-global/bin:$PATH # 위에서 생성한 npm global install을 위한 dir경로

.profile 수정 후에는 변경사항을 적용시켜야 한다.

1
$ source ~/.profile

2. 디렉토리 권한 수정

1번의 과정을 거친 후에도 다시 npm install -g yo 실행 시 아래와 같은 오류 발생

오류 내용이 길어서 전체 내용 확인이 필요한 경우 에러 내용에 명시된 로그파일 /home/hyper/.npm/_logs/2018-08-17T02_14_30_188Z-debug.log을 통해 확인할 수 있다.

  1. 에러 로그
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
npm WARN checkPermissions Missing write access to /home/hyper/.npm-global/lib/node_modules/yo
npm WARN checkPermissions Missing write access to /home/hyper/.npm-global/lib/node_modules/yo/node_modules
npm ERR! path /home/hyper/.npm-global/lib/node_modules/yo
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/home/hyper/.npm-global/lib/node_modules/yo'
npm ERR! { Error: EACCES: permission denied, access '/home/hyper/.npm-global/lib/node_modules/yo'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/home/hyper/.npm-global/lib/node_modules/yo\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/home/hyper/.npm-global/lib/node_modules/yo' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR! /home/hyper/.npm/_logs/2018-08-17T02_14_30_188Z-debug.log
  1. 에러 로그에 명시된 access 오류가 발생하는 디렉토리 권한 수정
1
2
3
$ sudo chown -R hyper /home/hyper/.npm-global
$ npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
  1. Yeoman 설치
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ npm install -g yo
/home/hyper/.npm-global/bin/yo -> /home/hyper/.npm-global/lib/node_modules/yo/lib/cli.js
/home/hyper/.npm-global/bin/yo-complete -> /home/hyper/.npm-global/lib/node_modules/yo/lib/completion/index.js

> yo@2.0.5 postinstall /home/hyper/.npm-global/lib/node_modules/yo
> yodoctor

Yeoman Doctor
Running sanity checks on your system

✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ yo version

Everything looks all right!
+ yo@2.0.5
removed 1 package and updated 6 packages in 27.231s
hyper@DESKTOP-BOKQP6N:~$