From 11183271114f2f23850695147398820927cc1abb Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 15 Apr 2018 14:39:41 -0400 Subject: [PATCH] feat: add warning about node version on startup (close #51) --- bin/vuepress.js | 13 ++++++++++++- package.json | 1 + yarn.lock | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/vuepress.js b/bin/vuepress.js index cb5c9ca330..a1b8c18233 100755 --- a/bin/vuepress.js +++ b/bin/vuepress.js @@ -1,7 +1,18 @@ #!/usr/bin/env node -const path = require('path') const chalk = require('chalk') +const semver = require('semver') +const requiredVersion = require('../package.json').engines.node + +if (!semver.satisfies(process.version, requiredVersion)) { + console.log(chalk.red( + `You are using Node ${process.version}, but VuePress ` + + `requires Node ${requiredVersion}.\nPlease upgrade your Node version.` + )) + process.exit(1) +} + +const path = require('path') const { dev, build } = require('../lib') const program = require('commander') diff --git a/package.json b/package.json index 97da12e002..36acaedd07 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "prismjs": "^1.13.0", "register-service-worker": "^1.2.0", "rimraf": "^2.6.2", + "semver": "^5.5.0", "stylus": "^0.54.5", "stylus-loader": "^3.0.2", "url-loader": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index b3bced4acd..3eec866b3a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5077,7 +5077,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@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"