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"
31 try { Install-Product node $env:nodejs_version -ErrorAction Stop }
32 catch { Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) x64 }
35 npm config set loglevel error
36 if ((npm config get package-lock) -eq "true") {
37 npm config set package-lock false
39 npm config set shrinkwrap false
41 # Remove all non-test dependencies
43 # Remove example dependencies
44 npm rm --silent --save-dev connect-redis
45 # Remove lint dependencies
46 cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | `
47 sls "^eslint(-|$)" | `
48 %{ npm rm --silent --save-dev $_ }
49 # Setup Node.js version-specific dependencies
52 # - use 3.x for Node.js < 4
53 # - use 5.x for Node.js < 6
54 # - use 6.x for Node.js < 8
55 # - use 7.x for Node.js < 10
56 # - use 8.x for Node.js < 12
57 # - use 9.x for Node.js < 14
58 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
59 npm install --silent --save-dev mocha@3.5.3
60 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
61 npm install --silent --save-dev mocha@5.2.0
62 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
63 npm install --silent --save-dev mocha@6.2.2
64 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) {
65 npm install --silent --save-dev mocha@7.2.0
66 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 12) {
67 npm install --silent --save-dev mocha@8.4.0
68 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 14) {
69 npm install --silent --save-dev mocha@9.2.2
72 # nyc for test coverage
73 # - use 10.3.2 for Node.js < 4
74 # - use 11.9.0 for Node.js < 6
75 # - use 14.1.1 for Node.js < 10
76 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
77 npm install --silent --save-dev nyc@10.3.2
78 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
79 npm install --silent --save-dev nyc@11.9.0
80 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) {
81 npm install --silent --save-dev nyc@14.1.1
84 # supertest for http calls
85 # - use 2.0.0 for Node.js < 4
86 # - use 3.4.2 for Node.js < 7
87 # - use 6.1.6 for Node.js < 8
88 if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
89 npm install --silent --save-dev supertest@2.0.0
90 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 7) {
91 npm install --silent --save-dev supertest@3.4.2
92 } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
93 npm install --silent --save-dev supertest@6.1.6
95 # Update Node.js modules
97 # Prune & rebuild node_modules
98 if (Test-Path -Path node_modules) {
102 # Install Node.js modules
106 # Output version data