How to specify/enforce a specific node.js version to use in package.json?

后端 未结 4 2224
北荒
北荒 2021-02-07 06:35

I am searching for a way to break the build, if a user is using a different node.js version as defined in the project.

Ideally to put some checks in grunt or bower or np

4条回答
  •  不要未来只要你来
    2021-02-07 07:07

    You can use the engines property in the package.json file

    For example, if you want to make sure that you have a minimum of node.js version 6.9 and a maximum of 6.10, then you can specify the following

    package.json
    {
        "name": "Foo",
        ....
        "engines": {
            "node": ">=6.9 <=6.10"
        }
    }
    

提交回复
热议问题