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

Even though engineStrict is deprecated, you can still accomplish this behavior without needing to use an additional script to enforce a Node version in your project.

  1. Add the engines property to your package.json file. For example:

    {
      "name": "example",
      "version": "1.0.0",
      "engines": {
       "node": ">=14.0.0"
      }
    }
    
  2. Create a .npmrc file in your project at the same level as your package.json.

  3. In the newly created .npmrc file, add engine-strict=true.

    engine-strict=true
    

This will enforce the engines you’ve defined when the user runs npm install. I’ve created a simple example on GitHub for your reference.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)