Run script only if specific version of node is detected

时间:2018-03-25 20:16:42

标签: node.js nodes node-modules

I have a very hack-ish script to deal with a problem present only in node v6.

I have the following in my package.json:

"scripts": {
    "pretest": "npm run target-2016 && tsc",

I want to run target-2016 only on node v6 (boron), is it possible?

1 个答案:

答案 0 :(得分:1)

You could do something with the output of npm -v. I'm not sure if I would try and put it all in package.json, so maybe an external script for something like this would be good.