You can use something like this,
Add a custom "install" script in your package.json file.
{
  "name": "custominstall",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "custom-install": "node custom-install"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "^2.0.6"
  }
}
Create custom-install.js in your root directory.
const { execSync } = require('child_process');
const packageJson = require('./package.json');
if (!packageJson.devDependencies.hasOwnProperty('nodemon')) {
    execSync(
        'npm install',
        {
            stdio: [
                0,
                1,
                2
            ]
        }
    );
} else {
    throw new Error('nodemon package should not be used in this project!');
}
This example code checks if nodemon package has been used as devDependency. Throws an error if it's used. Runs npm install and shows the command's output to you if it is not used.
You can customize it for your needs.
Use it like
npm run custom-install