turborepo + pnpm환경에서 package 설치이슈 (pnpm storybook)

junamee·2024년 1월 13일
0

기술메모

목록 보기
2/2

터보레포로 스토리북을 실행하는데 자꾸 에러가 뜬다.
m1 맥북 사용중이고 pnpm으로 설치했다. (에러메시지 하단 참고)

원인

  • arm칩을 사용하는 환경에서 js번들러 esbuild package가 darwin-x64로 설치되어서 storybook 실행에 오류가 발생함
  • arm칩에 맞는 esbuild package가 설치되어야하는데 환경적인 부분에서 이슈가 있는지 다른 package가 default로 설치됨

해결

  • 관련 이슈를 서치하는 도중 같은 이슈를 대응한 해결책을 발견하여 해결함github issue
  • 해결책: pnpm add -D @esbuild/darwin-x64 ->패키지 재설치하면 cpu환경에 맞게 arm64가 설치됨;

에러메시지

Error: 
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.

Specifically the "@esbuild/darwin-x64" package is present but this platform
needs the "@esbuild/darwin-arm64" package instead. People often get into this
situation by installing esbuild with npm running inside of Rosetta 2 and then
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
2 is Apple's on-the-fly x86_64-to-arm64 translation service).

If you are installing with npm, you can try ensuring that both npm and node are
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
changing how you installed npm and/or node. For example, installing node with
the universal installer here should work: https://nodejs.org/en/download/. Or
you could consider using yarn instead of npm which has built-in support for
installing a package on multiple platforms simultaneously.

If you are installing with yarn, you can try listing both "arm64" and "x64"
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.

Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.

*arm64와 x64는 CPU 아키텍처를 나타내는 용어

  • ARM64 (ARM 아키텍처):
    주로 모바일 기기(스마트폰, 태블릿)와 임베디드 시스템에 사용됩니다.
    전력 효율성이 높고, 모바일 기기에서 배터리 수명을 개선하는 데 중점을 둡니다.
    ARM 프로세서는 주로 에너지 효율적이며 작은 크기의 장치에서 선호됩니다. Apple의 M1 칩은 ARM64 아키텍처를 기반으로 합니다.
    Qualcomm, Samsung, MediaTek 등이 제조하는 모바일 기기에 ARM64 아키텍처를 사용합니다.

  • x64 (x86-64 또는 AMD64 아키텍처):
    주로 서버 및 개인 컴퓨터에서 사용됩니다.
    64비트 아키텍처로, 더 많은 주소 공간과 높은 성능을 제공합니다.
    대부분의 데스크탑 및 노트북 컴퓨터에서 x64 아키텍처를 사용합니다.

profile
아티클리스트 - bit.ly/3wjIlZJ

0개의 댓글