
특정 프로젝트를 진행하다보면
낮은 버전의 node를 사용할 때가 발생한다.
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:326:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:365:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1067:16)
npm ERR! gyp ERR! stack at Socket.<anonymous> (node:internal/child_process:453:11)
npm ERR! gyp ERR! stack at Socket.emit (node:events:365:28)
npm ERR! gyp ERR! stack at Pipe.<anonymous> (node:net:661:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "D:\\www\\wegrow\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\www\wegrow\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.1.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm install
를 진행하다보면 이러한 에러가 발생할 것이다.
전부는 아니겠지만 node버전이 달라서 발생하는 오류 일 것이다.
자 그럼 노드 버전을 변경해보자
노드 버전을 변경하기 위해선 먼저 nvm을 설치해야한다.
nvm (node version manager)
노드 버전 관리를 위한 도구
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
설치가 완료되면
nano 혹은 cat vi 기타 등등 에디터를 활용하여
.bash_profile 파일을 수정해준다.
nano ~/.bash_profile
로 파일을 오픈한 뒤
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
해당 텍스트를 삽입해준다.
그 후 파일을 설치해준다.
source ~/.bash_profile
마지막으로
nvm ls
를 사용하여 설치가 완료되었는 지 확인한다.
Node란
Node.js는 확장성 있는 네트워크 애플리케이션 개발에 사용되는 소프트웨어 플랫폼이다. 작성 언어로 자바스크립트를 활용하며 논블로킹 I/O와 단일 스레드 이벤트 루프를 통한 높은 처리 성능
-위키백과
nvm install 설치버전
nvm use 해당버전
node -v
d