Skip to content

Yarn

Yarn caches every package it downloads so it never needs to download it again. It also parallelizes operations to maximize resource utilization so install times are faster than ever.

Categories

Command

프로젝트를 시작할 때 초기화를 하려면(package.json을 생성합니다.)

$ yarn init

package.json으로부터 의존성 모듈을 설치하려면

$ yarn
# or
$ yarn install

의존성 모듈을 설치하려면 (npm install --save 와 동일하다)

$ yarn add [package]
$ yarn add [package]@[version]
$ yarn add [package]@[tag]

참고로 전역 설치는 (npm install -g와 동일하다)

$ yarn global add [package_name]

devDependencies, peerDependencies, optionalDependencies와 같은 다른 범주의 의존성을 추가하려면

$ yarn add [package] --dev
$ yarn add [package] --peer
$ yarn add [package] --optional

의존성 모듈을 업그레이드하려면

$ yarn upgrade [package]
$ yarn upgrade [package]@[version]
$ yarn upgrade [package]@[tag]

의존성 모듈을 제거하려면

$ yarn remove [package]

설치된 패키지 목록:

$ yarn list

설치된 모듈의 실행파일 실행.

$ yarn exec {executable file}

v1 과 v2 명령 비교

Yarn Classic (1.x)

Yarn (2.x)

Notes

yarn audit

yarn npm audit

yarn create

yarn dlx create-<name>

</code>yarn create</code> still works, but prefer using yarn dlx

yarn global

yarn dlx

Dedicated section

yarn info

yarn npm info

yarn login

yarn npm login

yarn logout

yarn npm logout

yarn outdated

yarn upgrade-interactive

Read more on GitHub

yarn publish

yarn npm publish

yarn tag

yarn npm tag

yarn upgrade

yarn up

Will now upgrade packages across all workspaces

yarn install --production

yarn workspaces focus --all --production

Requires the workspace-tools plugin

yarn install --verbose

<code>YARN_ENABLE_INLINE_BUILDS=true yarn install

yarn.lock

package.json파일은 Semantic versioning 규칙에 따라 패키지를 다운받기 때문에 시간이 지남에 따라 다운받는 버전이 달라질 수 있다. 따라서 yarn.lock 파일을 생성하여, 설치된 모듈의 버전을 저장해 어디서나 같은 버전과 구조의 의존성을 가지게 합니다.

즉, 이 파일은.gitignore파일에추가해선 안된다.

yarn에서는 자동으로 yarn install때 마다 yarn.lock이 생성됩니다. package-lock.json와 비슷한 기능을 한다고 생각하면 됩니다.

Publish

Npm#Publish 와 명령은 동일하다. 단, Npm#Login을 참고하여 npm으로 로그인한 후, 퍼블리싱 하면 된다.

yarn publish --access=public

npx 사용 방법

ynpx 설치를 고려해 보거나 package.json 파일의 script 에 명령을 추가하여 사용하자.

{
  "scripts": {
    "11ty": "npx @11ty/eleventy"
  }
}

Plugin

Troubleshooting

Extracting tar content of undefined failed

$HOME 디렉토리에서 빌드하지 말라.

The engine "node" is incompatible with this module

next@14.0.3: The engine "node" is incompatible with this module. Expected version ">=18.17.0". Got "18.16.1"

Node.js 버전을 업그레이드 하자.

Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated

warning accept-language > stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility

See also

  • npm
  • pixi - Conda 에코시스템을 위한 새 패키지 매니저

Favorite site