LoginSignup
0
0

More than 5 years have passed since last update.

Node.jsのCLIツールで、Node.jsのバージョンを確認する

Posted at

Ionicのソースみていて、あとで使えそうな気がしたので覚書。

IonicのCLIコマンド初期化時にこういうコードが走る。

var semver = require('semver');

if (semver.lt(process.version, 'v6.4.0')) {
  console.log('ERR: Your Node.js version is ' + process.version + '. Please update to the latest Node 8 LTS.');
  process.exit(1);
}

semberでproccess.versionの値を比較して、古いならerrorでexitする。

あとこれも何気に便利そうな気はしている。

process.on('unhandledRejection', function(r) { console.error(r); });
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0