mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
compare specific versions
This commit is contained in:
parent
0c6f71c82f
commit
be37742a46
@ -1,15 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const { red, green, bold } = require('chalk');
|
||||
const semver = require('semver');
|
||||
|
||||
module.exports = function checkBeforeInstall() {
|
||||
const currentNodeVersion = process.versions.node;
|
||||
const semver = currentNodeVersion.split('.');
|
||||
const major = semver[0];
|
||||
const minNodeVersion = '14.19.1'; // greater than or equal to this
|
||||
const maxNodeVersion = '17.0.0'; // less than this
|
||||
|
||||
if (major < 14 || major > 16) {
|
||||
console.error(red(`You are running ${bold(`Node ${currentNodeVersion}`)}`));
|
||||
console.error(`Strapi requires ${bold(green('Node 14 or 16'))}`);
|
||||
if (
|
||||
!semver.gte(currentNodeVersion, minNodeVersion) ||
|
||||
!semver.lt(currentNodeVersion, maxNodeVersion)
|
||||
) {
|
||||
console.error(red(`You are running ${bold(`node ${currentNodeVersion}`)}`));
|
||||
console.error(
|
||||
`Strapi requires ${bold(green(`node >=${minNodeVersion} and <${maxNodeVersion}`))}`
|
||||
);
|
||||
console.error('Please make sure to use the right version of Node.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
"node-machine-id": "^1.1.10",
|
||||
"ora": "^5.4.1",
|
||||
"tar": "6.1.11",
|
||||
"semver": "^7.3.4",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user