mirror of
https://github.com/strapi/strapi.git
synced 2025-11-05 12:24:35 +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,
|
...packageJsonStrapi,
|
||||||
},
|
},
|
||||||
engines: {
|
engines: {
|
||||||
node: '>=12.x.x <=16.x.x',
|
node: '>=14.19.1 <=16.x.x',
|
||||||
npm: '>=6.0.0',
|
npm: '>=6.0.0',
|
||||||
},
|
},
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
|
|||||||
@ -1,14 +1,28 @@
|
|||||||
'use strict';
|
'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() {
|
module.exports = function checkBeforeInstall() {
|
||||||
const currentNodeVersion = process.versions.node;
|
const currentNodeVersion = process.versions.node;
|
||||||
const semver = currentNodeVersion.split('.');
|
const { engines } = packageJSON({ strapiDependencies: [] });
|
||||||
const major = semver[0];
|
|
||||||
|
|
||||||
if (major < 12) {
|
// error if the node version isn't supported
|
||||||
console.error(`You are running Node ${currentNodeVersion}`);
|
if (!semver.satisfies(currentNodeVersion, engines.node)) {
|
||||||
console.error('Strapi requires Node 12 and higher.');
|
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.');
|
console.error('Please make sure to use the right version of Node.');
|
||||||
process.exit(1);
|
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",
|
"node-machine-id": "^1.1.10",
|
||||||
"ora": "^5.4.1",
|
"ora": "^5.4.1",
|
||||||
"tar": "6.1.11",
|
"tar": "6.1.11",
|
||||||
|
"semver": "^7.3.4",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.x.x <=16.x.x",
|
"node": ">=14.19.1 <=16.x.x",
|
||||||
"npm": ">=6.0.0"
|
"npm": ">=6.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user