무슨 차이일까?
Nodejs 문서를 살펴보면..
It returns the current working directory of the Node.js process
.
The directory name of the current module
.
둘은 모두 경로를 출력하는 함수이나 그 '스코프' 가 다르다는 것을 눈치챌 수 있다.
process.cwd()
는 Nodejs 프로세스가 돌아가고 있는 Working directory를 출력하는 반면, __dirname
은 해당 모듈의 경로를 출력한다.