2019-10-14 16:14:34 +02:00
|
|
|
'use strict';
|
|
|
|
|
2022-08-03 13:58:01 +02:00
|
|
|
const { red, green, bold } = require('chalk');
|
2022-08-03 15:57:26 +02:00
|
|
|
const semver = require('semver');
|
2022-08-03 13:58:01 +02:00
|
|
|
|
2019-10-14 16:14:34 +02:00
|
|
|
module.exports = function checkBeforeInstall() {
|
2022-08-03 13:58:01 +02:00
|
|
|
const currentNodeVersion = process.versions.node;
|
2022-08-03 15:57:26 +02:00
|
|
|
const minNodeVersion = '14.19.1'; // greater than or equal to this
|
|
|
|
const maxNodeVersion = '17.0.0'; // less than this
|
2019-10-14 16:14:34 +02:00
|
|
|
|
2022-08-03 15:57:26 +02:00
|
|
|
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}`))}`
|
|
|
|
);
|
2019-10-14 16:14:34 +02:00
|
|
|
console.error('Please make sure to use the right version of Node.');
|
2022-08-04 12:41:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// only exit on lower version; higher version is allowed to proceed with only the warning
|
|
|
|
if (!semver.gte(currentNodeVersion, minNodeVersion)) {
|
2019-10-14 16:14:34 +02:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
};
|