Q:

Using NodeJS development dependencies in Heroku review-app post-deploy step

I have a (demo) application hosted on Heroku. I've enabled Heroku's "review app" feature to spin up new instances for pull request reviews. These review instances all get a new MongoDB (on mLab) provisioned for them through Heroku's add-on system. This works great.
In my repository, I've defined some seeder scripts to quickly get a test database up and running. Running yarn seed (or npm run seed) will fill the database with test data. This works great during development, and it would be perfect for review apps as well. I want to execute the seeder command in the postdeploy hook of the Heroku review app, which can be done by specifying it under the environment.review section of the app.json file. Like so:
{
  "name": "...",
  "addons": [
    "mongolab:sandbox"
  ],
  "environments": {
    "review": {
      "addons": [
        "mongolab"
      ],
      "scripts": {
        "postdeploy": "npm run seed"
      }
    }
  }
}

The problem is, the seeder script relies on some development-only dependencies (faker, ts-node [this is a TypeScript project], and mongo-seeding) to execute. And these dependencies are not available in the postdeploy phase of an Heroku app.
I also don't think that "compiling" the typescript in the regular build step is the best idea. This seeder script is only used in development (and review apps). Besides, I'm not sure that would resolve the issue with missing dependencies like faker.
How would one go about this? Any tricks I'm missing?
Can I maybe skip Heroku's step where it actively deletes development dependencies? But only for review apps? Or even better, can I "exclude" just the couple of dependencies I need, and only for review apps?

A:

The Heroku docs indicate that when the NODE_ENV variable contains anything but "production", the devDependencies will not be removed after the build step.
To make sure this only happens for Heroku review apps, you can set the NODE_ENV variable under the environments.review section of the app.json file. The following config should do the trick:
{
  "name": "...",
  "addons": [
    "mongolab"
  ],
  "environments": {
    "review": {
      "addons": [
        "mongolab:sandbox"
      ],
      "env": {
        "NODE_ENV": "development"
      },
      "scripts": {
        "postdeploy": "npm run seed"
      }
    }
  }
}

