Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run migration X. This workspace is NOT up to date! The "path" argument must be of type string/Cannot find module X. #28726

Open
1 of 4 tasks
dfmpinto opened this issue Oct 31, 2024 · 0 comments

Comments

@dfmpinto
Copy link

dfmpinto commented Oct 31, 2024

Current Behavior

Hi!
I'm having troubles executing a migration. I created a repository with a simple setup, therefore you can test it and get the errors I'm getting.
Here are the steps I did to get the error:

  1. Created an nx workspace and generated mylibA.
  2. I locally published v0.0.1 to verdaccio and install it in my nx workspace package.json as a dependency.
  3. Then, I generated a migration for mylibA with version v0.0.2, built it and published to verdaccio once again.
  4. I ran the command nx migrate @nx-migration/mylibA@0.0.2 and it was successful. It generated migrations.json and updated the package.json.
  5. I ran npm install.
  6. Finally, ran nx migrate --run-migrations and got the following errors:
    a. "Failed to run update-0.0.2 from @nx-migration/mylibA. This workspace is NOT up to date!"
    b. "The "path" argument must be of type string or an instance of Buffer or URL. Received null" or "Cannot find module 'C:\Test\nx-migration\node_modules@nx-migration\mylibA/./src/migrations/update-0.0.2/update-0.0.2'"

I'm having trouble in a different project where I publish my library to GitHub Packages and use it in other projects, however I created this setup so you could reproduce it more easily.

I have tried a lot of workarounds and nothing seems to work.

Best regards,
Diogo Pinto

Expected Behavior

The command nx migrate --run-migrations is executed successfully.

GitHub Repo

https://github.com/dfmpinto/nx-migration

Steps to Reproduce

  1. npm install
  2. nx build mylibA
  3. Publish mylibA with v0.0.1 to local registry (such as, verdaccio running in docker container)
  4. Add "@nx-migration/mylibA": "0.0.1" to workspace package.json
  5. npm install
  6. nx generate @nx/plugin:migration libs/mylibA/src/migrations/update-0.0.2 --packageVersion=0.0.2
  7. Bump mylibA package.json version to 0.0.2
  8. nx build mylibA
  9. Publish mylibA with v0.0.2 to local registry (such as, verdaccio)
  10. nx migrate @nx-migration/mylibA@0.0.2
  11. npm install
  12. nx migrate --run-migrations

Nx Report

nx report

NX Report complete - copy this into the issue template

Node : 22.11.0
OS : win32-x64
Native Target : x86_64-windows
npm : 10.9.0

nx (global) : 20.0.6
nx : 20.0.6
@nx/js : 20.0.6
@nx/jest : 20.0.6
@nx/eslint : 20.0.6
@nx/workspace : 20.0.6
@nx/devkit : 20.0.6
@nx/esbuild : 20.0.6
@nx/eslint-plugin : 20.0.6
@nx/plugin : 20.0.6
typescript : 5.5.4

Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

First time:

nx migrate --run-migrations --verbose

NX Running migrations from 'migrations.json'

Running the following migrations:

  • @nx-migration/mylibA: update-0.0.3 (Migration for v0.0.3)

Running migration @nx-migration/mylibA: update-0.0.3

NX Failed to run update-0.0.3 from @nx-migration/mylibA. This workspace is NOT up to date!

NX The "path" argument must be of type string or an instance of Buffer or URL. Received null

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received null
at readFileSync (node:fs:439:14)
at readJsonFile (C:\Test\nx-migration\node_modules\nx\src\utils\fileutils.js:27:48)
at readMigrationCollection (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1056:53)
at executeMigrations (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:919:52)
at runMigrations (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1009:43)
at C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1050:19
at async handleErrors (C:\Test\nx-migration\node_modules\nx\src\utils\handle-errors.js:9:24)


Second Time:

nx migrate --run-migrations --verbose

NX Running migrations from 'migrations.json'

Running the following migrations:

  • @nx-migration/mylibA: update-0.0.3 (Migration for v0.0.3)

Running migration @nx-migration/mylibA: update-0.0.3

NX Failed to run update-0.0.3 from @nx-migration/mylibA. This workspace is NOT up to date!

NX Cannot find module 'C:\Test\nx-migration\node_modules@nx-migration\mylibA/./src/migrations/update-0.0.3/update-0.0.3'

Require stack:

  • C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js
  • C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\command-object.js
  • C:\Test\nx-migration\node_modules\nx\src\command-line\nx-commands.js
  • C:\Test\nx-migration\node_modules\nx\bin\init-local.js
  • C:\Test\nx-migration\node_modules\nx\bin\nx.js
    Error: Cannot find module 'C:\Test\nx-migration\node_modules@nx-migration\mylibA/./src/migrations/update-0.0.3/update-0.0.3'
    Require stack:
  • C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js
  • C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\command-object.js
  • C:\Test\nx-migration\node_modules\nx\src\command-line\nx-commands.js
  • C:\Test\nx-migration\node_modules\nx\bin\init-local.js
  • C:\Test\nx-migration\node_modules\nx\bin\nx.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
    at Function.resolve (node:internal/modules/helpers:151:19)
    at getImplementationPath (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1078:28)
    at runNxMigration (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1033:42)
    at executeMigrations (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:921:39)
    at runMigrations (C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1009:43)
    at C:\Test\nx-migration\node_modules\nx\src\command-line\migrate\migrate.js:1050:19
    at async handleErrors (C:\Test\nx-migration\node_modules\nx\src\utils\handle-errors.js:9:24)

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant