3 - nodejs_version: "0.10"
4 - nodejs_version: "0.12"
5 - nodejs_version: "1.8"
6 - nodejs_version: "2.5"
7 - nodejs_version: "3.3"
8 - nodejs_version: "4.9"
9 - nodejs_version: "5.12"
10 - nodejs_version: "6.17"
11 - nodejs_version: "7.10"
12 - nodejs_version: "8.17"
13 - nodejs_version: "9.11"
14 - nodejs_version: "10.24"
15 - nodejs_version: "11.15"
16 - nodejs_version: "12.22"
17 - nodejs_version: "13.14"
18 - nodejs_version: "14.20"
19 - nodejs_version: "15.14"
20 - nodejs_version: "16.20"
21 - nodejs_version: "17.9"
22 - nodejs_version: "18.19"
23 - nodejs_version: "19.9"
24 - nodejs_version: "20.11"
25 - nodejs_version: "21.6"
26 - nodejs_version: "22.0"
32 try { Install-Product node $env:nodejs_version -ErrorAction Stop }
33 catch { Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) x64 }
36 npm config set loglevel error
37 if ((npm config get package-lock) -eq "true") {
38 npm config set package-lock false
40 npm config set shrinkwrap false
42 # Remove all non-test dependencies
44 # Remove example dependencies
45 npm rm --silent --save-dev connect-redis
46 # Remove lint dependencies
47 cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | `
48 sls "^eslint(-|$)" | `
49 %{ npm rm --silent --save-dev $_ }
50 # Setup Node.js version-specific dependencies
53 # - use 3.x for Node.js < 4
54 # - use 5.x for Node.js < 6
55 # - use 6.x for Node.js < 8
56 # - use 7.x for Node.js < 10
57 # - use 8.x for Node.js < 12
58 # - use 9.x for Node.js < 14
59 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
60 npm install --silent --save-dev mocha@3.5.3
61 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
62 npm install --silent --save-dev mocha@5.2.0
63 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
64 npm install --silent --save-dev mocha@6.2.2
65 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) {
66 npm install --silent --save-dev mocha@7.2.0
67 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 12) {
68 npm install --silent --save-dev mocha@8.4.0
69 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 14) {
70 npm install --silent --save-dev mocha@9.2.2
73 # nyc for test coverage
74 # - use 10.3.2 for Node.js < 4
75 # - use 11.9.0 for Node.js < 6
76 # - use 14.1.1 for Node.js < 10
77 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
78 npm install --silent --save-dev nyc@10.3.2
79 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
80 npm install --silent --save-dev nyc@11.9.0
81 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) {
82 npm install --silent --save-dev nyc@14.1.1
85 # supertest for http calls
86 # - use 2.0.0 for Node.js < 4
87 # - use 3.4.2 for Node.js < 7
88 # - use 6.1.6 for Node.js < 8
89 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
90 npm install --silent --save-dev supertest@2.0.0
91 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 7) {
92 npm install --silent --save-dev supertest@3.4.2
93 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
94 npm install --silent --save-dev supertest@6.1.6
96 # Update Node.js modules
98 # Prune & rebuild node_modules
99 if (Test-Path -Path node_modules) {
103 # Install Node.js modules
107 # Output version data