Skip to content

Commit 3398b1b

Browse files
authored
build: require minimum NPM version #3959
Problem: Developers may have outdated tooling, which causes weird problems. Solution: - Define minimum npm version and enforce it via `.npmrc`. Outdated npm will show an error like: ``` $ npm install npm ERR! code EBADENGINE npm ERR! engine Unsupported engine npm ERR! engine Not compatible with your version of node/npm: [email protected] npm ERR! notsup Not compatible with your version of node/npm: [email protected] npm ERR! notsup Required: {"npm":"^10.1.0","vscode":"^1.68.0"} npm ERR! notsup Actual: {"npm":"10.0.0","node":"v20.8.0"} ``` - Disable the check in CI. Because it's transitive, random dependencies like "marked" can pointlessly require aggressively-recent versions of NPM, which isn't feasible for us to support in our CI: ``` npm ERR! engine Not compatible with your version of node/npm: [email protected] npm ERR! notsup Not compatible with your version of node/npm: [email protected] npm ERR! notsup Required: {"node":">= 18"} npm ERR! notsup Actual: {"npm":"8.19.4","node":"v16.20.2"} ```
1 parent e7b652d commit 3398b1b

File tree

8 files changed

+17
-0
lines changed

8 files changed

+17
-0
lines changed

.github/workflows/node.js.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
NODE_OPTIONS: '--max-old-space-size=8192'
2424
steps:
2525
- uses: actions/checkout@v4
26+
- name: Disable engine-strict check
27+
run: sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
2628
- name: Use Node.js ${{ matrix.node-version }}
2729
uses: actions/setup-node@v4
2830
with:
@@ -65,6 +67,8 @@ jobs:
6567
NODE_OPTIONS: '--max-old-space-size=8192'
6668
steps:
6769
- uses: actions/checkout@v4
70+
- name: Disable engine-strict check
71+
run: sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
6872
- name: Use Node.js ${{ matrix.node-version }}
6973
uses: actions/setup-node@v4
7074
with:
@@ -94,6 +98,8 @@ jobs:
9498
NODE_OPTIONS: '--max-old-space-size=8192'
9599
steps:
96100
- uses: actions/checkout@v4
101+
- name: Disable engine-strict check
102+
run: sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
97103
- name: Use Node.js ${{ matrix.node-version }}
98104
uses: actions/setup-node@v4
99105
with:

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

buildspec/linuxE2ETests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ phases:
2020

2121
build:
2222
commands:
23+
# Disable engine-strict in CI.
24+
- sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
2325
- npm ci --unsafe-perm
2426
# We cannot run `code` as root during tests
2527
# From: https://github.com/aws/aws-codebuild-docker-images/blob/2f796bb9c81fcfbc8585832b99a5f780ae2b2f52/ubuntu/standard/6.0/Dockerfile#L56

buildspec/linuxIntegrationTests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ phases:
2222
java: latest
2323

2424
commands:
25+
# Disable engine-strict in CI.
26+
- sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
2527
- '>/dev/null add-apt-repository universe'
2628
- '>/dev/null apt-get -qq install -y apt-transport-https'
2729
- '>/dev/null apt-get -qq update'

buildspec/linuxTests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ phases:
1313
runtime-versions:
1414
nodejs: 16
1515
commands:
16+
# Disable engine-strict in CI.
17+
- sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
1618
# Without this, "Unable to locate package libatk1.0-0".
1719
- '>/dev/null apt-get -yqq update'
1820
# Dependencies for running vscode.

buildspec/packageTestVsix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ phases:
1515
runtime-versions:
1616
nodejs: 16
1717
commands:
18+
# Disable engine-strict in CI.
19+
- sed -i -e 's/engine.strict.true/engine-strict=false/' .npmrc
1820
# Prepare env for unprivileged user.
1921
- |
2022
mkdir -p ~codebuild-user

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"url": "https://github.com/aws/aws-toolkit-vscode"
1414
},
1515
"engines": {
16+
"npm": "^10.1.0",
1617
"vscode": "^1.68.0"
1718
},
1819
"icon": "resources/marketplace/aws-icon-256x256.png",

0 commit comments

Comments
 (0)