How to specify the required Node.js version in package.json?

Sometimes, we want to specify the required Node.js version in package.json.

In this article, we’ll look at how to specify the required Node.js version in package.json.

How to specify the required Node.js version in package.json?

To specify the required Node.js version in package.json, we can set the engines.npm and engines.node property in package.json.

For instance, we write

"engines": {
  "npm": ">=7.0.0",
  "node": ">=16.0.0"
}

to set the required Node version to 16.0.0 or higher.

Conclusion

To specify the required Node.js version in package.json, we can set the engines.npm and engines.node property in package.json.