관리 메뉴

너와 나의 스토리

[M1] Homebrew 실행 안 될 때 / yarn 실행 안 되는 문제 해결 / python2 설치 본문

기타

[M1] Homebrew 실행 안 될 때 / yarn 실행 안 되는 문제 해결 / python2 설치

노는게제일좋아! 2023. 2. 21. 10:11
반응형

Homebrew 실행 문제

  • {$ brew config}해서 HOMEBREW_PREFIX 확인

 

원인

  • prefix 문제: /usr/local 이면 안 됨 -> /opt/homebrew여야 함

 

해결책

  • m1 Homebrew 다시 설치한 다음 다음의 명령어 실행
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • brew doctor 실행
    • $ /opt/homebrew/bin/brew doctor
  • 여기에 나오는대로 prefix 변경
    • $ echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc

 

Yarn 실행 문제

 

문제

  • yarn이 제대로 실행되지 않음. 아래의 에러 발생
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error

 

해결책 1

brew upgrade icu4c
brew upgrade
brew cleanup
  • 결과: 위 작업해도 동일한 문제 발생

 

 

해결책 2

 

 

+ Yarn 실행 문제

  • 다음날 다시 실행해보니 다른 문제 발생
  • 에러:
gyp verb check python checking for Python executable "python2" in the PATH
Can't find Python executable "python", you can set the PYTHON env variable.
  • python 2가 없어서 생기는 문제 같다.

 

해결책 1

Last 10 log lines:
		echo "generate-posix-vars failed" ; \
		rm -f ./pybuilddir.txt ; \
		exit 1 ; \
	fi
dyld[15770]: Library not loaded: /System/Library/Frameworks/Python.framework/Versions/2.7/Python
  Referenced from: /private/var/folders/2n/h7k861yx7q5b73vmch9tls080000gr/T/python-build.20230228001342.7329/Python-2.7.18/python.exe
  Reason: tried: '/System/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file), '/Library/Frameworks/Python.framework/Versions/2.7/Python' (no such file)
/bin/sh: line 1: 15770 Abort trap: 6           DYLD_LIBRARY_PATH=/var/folders/2n/h7k861yx7q5b73vmch9tls080000gr/T/python-build.20230228001342.7329/Python-2.7.18 ./python.exe -E -S -m sysconfig --generate-posix-vars
generate-posix-vars failed
make: *** [pybuilddir.txt] Error 1

 

 

해결책 2

Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-sass/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/opt/homebrew/Cellar/node/19.6.1/bin/node" "/Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-sass
gyp ERR! node -v v19.6.1
    • 위 에러는 binding.gyp 파일에서 standalone_static_library 변수가 정의되어 있지 않아서 발생하는 거라고 함.
    • 그래서 node-gyp 설치
      • node-gyp: Node.js addon을 빌드하기 위한 도구
      • $ npm install -g node-gyp
      • 소용없음
    • npm upgrade
      • "ERESOLVE could not resolve" 에러 발생
      • REACT_SPRING 설치 이슈 해결
        1. $ npm install --force
        2. $ npm audit fix --force
    • node 버전 확인
  • 다시 yarn 실행하니 성공!
  • 결론:
    • 원인 1: python2가 없어서
    • 원인 2: npm 설정이 꼬여서
    • 위 두 부분을 수정하니 yarn install 성공

 

 

yarn 패키지 의존성 문제

  • yarn install까지는 성공했는데 yarn start하니까 아래의 에러 발생
Cannot find module 'react-dev-utils/WatchMissingNodeModulesPlugin'
  • 해결책
    1. node_modules 폴더 삭제 후 재설치
      • $ rm -rf node_modules
      • $ npm install
    2. yarn.lock 파일 삭제 후 재설치
      • $ rm yarn.lock
      • $ yarn install
    3. 모듈 업데이트
      • $ yarn upgrade
    4. 패키지 의존성 확인
      • yarn add <package-name>
    5. 패키지 다시 clone..
      • 패키지 다시 clone해오기
      • 다시 yarn install을 하니 이번에는 아래의 에러가 발생한다.
error /Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments: 
Directory: /Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-sass
Output:
Building: /opt/homebrew/Cellar/node/19.6.1/bin/node /Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/opt/homebrew/Cellar/node/19.6.1/bin/node',
gyp verb cli   '/Users/seojeongyu/IdeaProjects/kakao/devicefarm-wfe/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
...
  • node-sass를 설치
    • $ yarn add node-sass
    • 다시 yarn install & start하니 드디어 성공!!
반응형
Comments