Closed krstns closed 7 months ago
Do you have a workspace.json in root directory? I just tried the migration by myself and encountered the same problem as you. My workspace.json looked like this:
{
"version": 2,
"projects": {
"ruder-challenge": "apps/ruder-challenge"
}
}
and I've changed it to
{
"version": 2,
"projects": {
"ruder-challenge": { "name": "ruder-challenge", "root": "apps/ruder-challenge" }
}
}
After that the migration-script worked (and correctly removed the workspace.json)
@bstelljes thanks for the info. I don't have workspace.json. I do still have angular.json file. I would expect that this would be a part of the migration process.
I've tried converting the angular.json file on my own and run migrations again, but I didn't go too far with it. The next error I get is:
[...]
UPDATE apps/core/project.json
---------------------------------------------------------
> NX Failed to run block-template-entities from @angular/core. This workspace is NOT up to date!
> NX import_typescript3.default.getDecorators is not a function
TypeError: import_typescript3.default.getDecorators is not a function
at /Users/krystian/projects/myproject/node_modules/@angular/core/schematics/migrations/block-template-entities/bundle.js:25408:57
at walk (/Users/krystian/projects/myproject/node_modules/@angular/core/schematics/migrations/block-template-entities/bundle.js:25480:7)
at visitNodes (/Users/krystian/projects/myproject/node_modules/typescript/lib/typescript.js:30672:30)
at Object.forEachChild (/Users/krystian/projects/myproject/node_modules/typescript/lib/typescript.js:30951:24)
at NodeObject.forEachChild (/Users/krystian/projects/myproject/node_modules/typescript/lib/typescript.js:163979:23)
at forEachClass (/Users/krystian/projects/myproject/node_modules/@angular/core/schematics/migrations/block-template-entities/bundle.js:25478:14)
at analyze (/Users/krystian/projects/myproject/node_modules/@angular/core/schematics/migrations/block-template-entities/bundle.js:25406:3)
at runBlockTemplateEntitiesMigration (/Users/krystian/projects/myproject/node_modules/@angular/core/schematics/migrations/block-template-entities/bundle.js:25505:5)
at SchematicImpl.<anonymous> (/Users/krystian/projects/myproject/node_modules/@angular/core/schematics/migrations/block-template-entities/bundle.js:25496:7)
at Generator.next (<anonymous>)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Command failed: yarn nx _migrate --run-migrations --verbose
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> NX Command failed: yarn nx migrate --run-migrations --verbose
Error: Command failed: yarn nx migrate --run-migrations --verbose
at checkExecSyncError (node:child_process:890:11)
at execSync (node:child_process:962:15)
at runNxSync (/private/var/folders/5_/t03cfbb54pq6jvlk4g14hrlh0000gn/T/tmp-44701-2G7qp9hGhAQl/node_modules/nx/src/utils/child-process.js:25:34)
at runMigrations (/private/var/folders/5_/t03cfbb54pq6jvlk4g14hrlh0000gn/T/tmp-44701-2G7qp9hGhAQl/node_modules/nx/src/command-line/migrate/migrate.js:940:39)
at /private/var/folders/5_/t03cfbb54pq6jvlk4g14hrlh0000gn/T/tmp-44701-2G7qp9hGhAQl/node_modules/nx/src/command-line/migrate/migrate.js:1034:19
at async handleErrors (/private/var/folders/5_/t03cfbb54pq6jvlk4g14hrlh0000gn/T/tmp-44701-2G7qp9hGhAQl/node_modules/nx/src/utils/params.js:9:16)
Command failed: /var/folders/5_/t03cfbb54pq6jvlk4g14hrlh0000gn/T/tmp-44701-2G7qp9hGhAQl/node_modules/.bin/nx _migrate --run-migrations --verbose
@krstns try deleting angular.json
file. It looks like it's not needed in newer versions.
In my case, I got far enough (after making those changes to create the object for each workspace) that the migration actually deleted the workspace.json completely. I was going from V15 to latest. I still have other errors to resolve though.
I was able to come back to this project and this issue now.
I have reverted all the changes made before and decided to do it differently.
Instead of making migration to latest I started to go one by one.
so first i ran:
nx migrate 15
It was only an update of the nx package without any migrations.
so far so good.
Then:
nx migrate 16
This time it updated the nx package and created migrations.
The first migration was the separation of angular.json contents into specific project files.
Just ran the migration and it went fine.
So my suggestion to anyone struggling with it - go one by one.
Thanks for reporting this!
@krstns as you've discovered, it's actually recommended to migrate one major version at a time. This is particularly more important for Angular projects. The @angular/core
package only keeps migrations for one major version. The Angular CLI doesn't support updating multiple major versions at a time, and therefore, their packages only contain migrations for any given current major version.
So, migrating over multiple major versions would lead to missing migrations and some other potential issues. It looks like you were able to solve the issue, so I'm going to close it. If someone else is still facing issues after following the above advise, please create a new issue and provide a reproduction so we can properly troubleshoot it.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
I've tried running the migration:
results in:
My angular.json file is v2:
Expected Behavior
Workspace migrated to latest nx.
GitHub Repo
No response
Steps to Reproduce
1.run the same commands on an nx 14.8.4 project with external and internal libraries.
Nx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
No response