mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
54 lines
1.5 KiB
JavaScript
Executable file
54 lines
1.5 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
const path = require('path');
|
|
|
|
// Make sure that it also find the config folder when it
|
|
// did get started from another folder that the root one.
|
|
process.env.NODE_CONFIG_DIR = process.env.NODE_CONFIG_DIR || path.join(__dirname, 'config');
|
|
|
|
// Check if version should be displayed
|
|
const versionFlags = ['-v', '-V', '--version'];
|
|
if (versionFlags.includes(process.argv.slice(-1)[0])) {
|
|
console.log(require('../package').version);
|
|
process.exit(0);
|
|
}
|
|
|
|
if (process.argv.length === 2) {
|
|
// When no command is given choose by default start
|
|
process.argv.push('start');
|
|
}
|
|
|
|
const nodeVersion = process.versions.node;
|
|
const { major, gte } = require('semver');
|
|
|
|
const MINIMUM_SUPPORTED_NODE_VERSION = '18.17.0';
|
|
const ENFORCE_MIN_NODE_VERSION = process.env.E2E_TESTS !== 'true';
|
|
|
|
if (
|
|
(ENFORCE_MIN_NODE_VERSION && !gte(nodeVersion, MINIMUM_SUPPORTED_NODE_VERSION)) ||
|
|
![18, 20, 22].includes(major(nodeVersion))
|
|
) {
|
|
console.log(`
|
|
Your Node.js version ${nodeVersion} is currently not supported by n8n.
|
|
Please use Node.js v${MINIMUM_SUPPORTED_NODE_VERSION} (recommended), v20, or v22 instead!
|
|
`);
|
|
process.exit(1);
|
|
}
|
|
|
|
// Disable nodejs custom inspection across the app
|
|
const { inspect } = require('util');
|
|
inspect.defaultOptions.customInspect = false;
|
|
|
|
require('express-async-errors');
|
|
require('source-map-support').install();
|
|
require('reflect-metadata');
|
|
|
|
if (process.env.NODEJS_PREFER_IPV4 === 'true') {
|
|
require('dns').setDefaultResultOrder('ipv4first');
|
|
}
|
|
|
|
(async () => {
|
|
const oclif = await import('@oclif/core');
|
|
await oclif.execute({ dir: __dirname });
|
|
})();
|