mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Merge pull request #13962 from strapi/fix/preinstall-node-version-check
Require Node >=14, <=16 to install Strapi
This commit is contained in:
commit
dece14c0de
@ -43,7 +43,7 @@ module.exports = (opts) => {
|
||||
...packageJsonStrapi,
|
||||
},
|
||||
engines: {
|
||||
node: '>=12.x.x <=16.x.x',
|
||||
node: '>=14.19.1 <=16.x.x',
|
||||
npm: '>=6.0.0',
|
||||
},
|
||||
license: 'MIT',
|
||||
|
||||
@ -1,14 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const { red, green, bold, yellow } = require('chalk');
|
||||
const semver = require('semver');
|
||||
const packageJSON = require('../resources/json/common/package.json');
|
||||
|
||||
module.exports = function checkBeforeInstall() {
|
||||
const currentNodeVersion = process.versions.node;
|
||||
const semver = currentNodeVersion.split('.');
|
||||
const major = semver[0];
|
||||
const { engines } = packageJSON({ strapiDependencies: [] });
|
||||
|
||||
if (major < 12) {
|
||||
console.error(`You are running Node ${currentNodeVersion}`);
|
||||
console.error('Strapi requires Node 12 and higher.');
|
||||
// error if the node version isn't supported
|
||||
if (!semver.satisfies(currentNodeVersion, engines.node)) {
|
||||
console.error(red(`You are running ${bold(`Node.js ${currentNodeVersion}`)}`));
|
||||
console.error(`Strapi requires ${bold(green(`Node.js ${engines.node}`))}`);
|
||||
console.error('Please make sure to use the right version of Node.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// warn if not using a LTS version
|
||||
else if (semver.satisfies(currentNodeVersion, '15.x.x || 17.x.x || 19.x.x')) {
|
||||
console.warn(yellow(`You are running ${bold(`Node.js ${currentNodeVersion}`)}`));
|
||||
console.warn(
|
||||
`Strapi only supports ${bold(
|
||||
green('LTS versions of Node.js')
|
||||
)}, other versions may not be compatible.`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -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": {
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12.x.x <=16.x.x",
|
||||
"node": ">=14.19.1 <=16.x.x",
|
||||
"npm": ">=6.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user