package.json
패키지의 매니페스트 파일입니다. 여기에는 의존성, 제목, 작성자 등을 포함한 모든 패키지의 메타데이터가 포함됩니다. 이것은 pnpm을 포함한 모든 주요 Node.js 패키지 관리자에서 유지되는 표준입니다.
engines
소프트웨어가 작동하는 Node 및 pnpm의 버전을 지정할 수 있습니다.
{
"engines": {
"node": ">=10",
"pnpm": ">=3"
}
}
로컬 개발 중에 버전이 engines 필드에 지정된 버전과 일치하지 않으면 pnpm은 항상 오류 메시지와 함께 실패합니다.
사용자가 engine-strict 구성 플래그를 설정하지 않은 경우( .npmrc참조), 이 필드는 권고 사항일 뿐이며 패키지가 의존성으로 설치된 경우에만 경고를 생성합니다.
dependenciesMeta
dependencies, optionalDependencies 및 devDependencies 내부에 선언된 종속성을 위한 추가적인 메타 정보입니다.
dependenciesMeta.*.injected
로컬 의존성에 대해 true로 설정되면, 패키지는 심볼릭 링크가 아닌 모듈 디렉토리에 하드 링크됩니다.
For instance, the following package.json in a workspace will create a symlink to button in the node_modules directory of card:
{
"name": "card",
"dependencies": {
"button": "workspace:1.0.0"
}
}
But what if button has react in its peer dependencies? If all projects in the monorepo use the same version of react, then no problem. But what if button is required by card that uses react@16 and form with react@17? Without using inject, you'd have to choose a single version of react and install it as dev dependency of button. But using the injected field you can inject button to a package, and button will be installed with the react version of that package.
So this will be the package.json of card:
{
"name": "card",
"dependencies": {
"button": "workspace:1.0.0",
"react": "16"
},
"dependenciesMeta": {
"button": {
"injected": true
}
}
}