-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcheckNodeVersion.js
More file actions
26 lines (26 loc) · 935 Bytes
/
checkNodeVersion.js
File metadata and controls
26 lines (26 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// compliments of: https://medium.com/codeptivesolutions/want-to-check-node-version-before-project-get-executed-using-script-47cd32c2f1fe
const result = process.versions;
if (result && result.node) {
if (parseInt(result.node) >= 16) {
console.log(
'\x1b[32m%s\x1b[0m',
`-------******* Good to Go with your Node Version: ${result.node} *******-------`
);
} else {
console.log(
'\x1b[31m%s\x1b[0m',
'-------******* Package installation(npm install) or Project startup command(npm start) failed due to Node Version, Please install and use Node Version >=8 *******-------'
);
console.log(
'\x1b[33m%s\x1b[0m',
`-------******* Your current Node Version is: ${result.node} *******-------`
);
process.exit(1);
}
} else {
console.log(
'\x1b[31m%s\x1b[0m',
'-------******* Something went wrong while checking Node version *******-------'
);
process.exit(1);
}