From ff8ffb95923a7fdf171590ab8f299b4f92ff7b61 Mon Sep 17 00:00:00 2001 From: NicoPennec Date: Tue, 30 Jan 2018 02:57:24 +0100 Subject: [PATCH] feat: check expectated node version --- bin/nuxt | 6 ++++++ package.json | 1 + yarn.lock | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/nuxt b/bin/nuxt index 3527686d53..a1ddd8b065 100755 --- a/bin/nuxt +++ b/bin/nuxt @@ -4,6 +4,8 @@ process.env.DEBUG = process.env.DEBUG || 'nuxt:*' const { join } = require('path') +const { name, engines } = require('../package.json') +const semver = require('semver') const { Utils } = require('..') // Global error handler @@ -11,6 +13,10 @@ process.on('unhandledRejection', _error => { Utils.printError(_error) }) +if (!semver.satisfies(process.version, engines.node)) { + Utils.fatalError(`The engine "node" is incompatible with ${name}. Expected version "${engines.node}".`) +} + const defaultCommand = 'dev' const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate']) diff --git a/package.json b/package.json index cfe2b586c4..74fb426902 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "postcss-url": "^7.3.0", "pretty-error": "^2.1.1", "progress-bar-webpack-plugin": "^1.10.0", + "semver": "^5.5.0", "serialize-javascript": "^1.4.0", "serve-static": "^1.13.1", "server-destroy": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index fbc6c802be..94890bb958 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6729,7 +6729,7 @@ semver-diff@^2.0.0: dependencies: semver "^5.0.3" -"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1: +"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"