컴퓨터 공학/JavaScript

Node.js 버전 강제하기

혼새미로 2022. 1. 19. 23:02
반응형

설정

루트 디렉토리에 .npmrc 파일 추가하기

engine-strict=true

package.json에 engines 속성 추가하기

{
	"engines": {
		"node": ">=14.16.0"
	}
}

사용자 관점

리파지토리 클론 후 npm install 입력 (버전 옵션 조건을 만족하지 못한 경우)

npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: js_test_01@1.0.0
npm ERR! notsup Not compatible with your version of node/npm: js_test_01@1.0.0
npm ERR! notsup Required: {"node":">=14.17.0"}
npm ERR! notsup Actual:   {"npm":"8.1.4","node":"v14.16.0"}

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\gshong33\AppData\Local\npm-cache\_logs\2022-01-12T04_27_38_437Z-debug.log

버전 옵션 예시

> 0.10.3 이상 0.12 이하인 경우

{
	"engines": {
		"node": ">=0.10.3 <0.12"
	}
}

 

반응형