본문 바로가기
FRONTEND/React

yarn 설치 시 오류

by 드로니뚜벅이 2022. 12. 20.

yarn을 사용하려면 node.js를 설치한 후 아래 명령어를 실행합니다.

$ corepack enable

그리고, yarn을 최신 버전으로 업데이트합니다.

$ yarn set version stable

 

정상적으로 설치했음에도 불구하고 아래와 같은 오류가 발생하는 경우가 있습니다.

$ yarn create react-app basic
➤ YN0000: ┌ Resolution step
➤ YN0061: │ tar@npm:2.2.2 is deprecated: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
➤ YN0000: └ Completed in 1s 499ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 1s 632ms


Creating a new React app in /home/yunny/programming/react/basic.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

Usage Error: The nearest package directory (/home/yunny/programming/react/basic) doesn't seem to be part of the project declared in /home/yunny.

- If /home/yunny isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If /home/yunny is intended to be a project, it might be that you forgot to list programming/react/basic in its workspace configuration.
- Finally, if /home/yunny is fine and you intend programming/react/basic to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.

$ yarn add [--json] [-E,--exact] [-T,--tilde] [-C,--caret] [-D,--dev] [-P,--peer] [-O,--optional] [--prefer-dev] [-i,--interactive] [--cached] [--mode #0] ...

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts cra-template --cwd /home/yunny/programming/react/basic has failed.

Deleting generated file... package.json
Deleting basic/ from /home/yunny/programming/react
Done.

메시지 내용에서 알 수 있듯이 상위 폴더에 package.json이나 yarn.lock 파일이 생성되어 있는 경우가 있습니다. 해당 파일을 삭제 후 다시 명령어를 실행하면 정상 동작합니다.