nx migrate - Skip npm install when running nx migrate --run-migration

Viewed 651

I am currently working on an analysis on upgrading my library and it's dependencies using nx migrate.

I have a question around nx migrate command. I want to test the upgrade related changes directly on local rather than uploading the package to the registry again and again.

But nx migrate --run-migrations runs npm install before running migration.json file's scripts which updates the node_modules packages.

So is it possible to skip npm install which runs right after running nx migrate --run-migrations?

ng update has a param --migrate-only which I guess runs only migration scripts. (https://angular.io/cli/update). I tried using --migrate-only with nx migrate, but it did not work.

Any other idea of testing upgrade related changes using nx migrate would be helpful.

1 Answers

If your migration file is already generated you could use NX_MIGRATE_SKIP_INSTALL=true nx migrate --run-migrations=migrations.json to run your migration and skip the npm install phase.

To create a migrations.json you can use this example:

{
  "migrations": [
    {
      "version": "1.33",
      "description": "update-1.33",
      "cli": "nx",
      "implementation": "./src/migrations/update-1.33/update-1.33",
      "package": "./dist/libs/your-path",
      "name": "update-1.33"
    }
  ]
}
Related