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

后端 未结 4 2223
北荒
北荒 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条回答
  •  萌比男神i
    2021-02-07 06:54

    If you want to enforce a specific version of npm, you might use: https://github.com/hansl/npm-enforce-version

    If you want to enforce a version of node when executing you can read the version of node that is currently running by checking against:

    process.versions

    For more info: https://nodejs.org/api/process.html#process_process_versions

提交回复
热议问题