Skip to content

Undecorated classes with DI migration not working TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string #33143

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

Closed
elvisbegovic opened this issue Oct 14, 2019 · 14 comments
Labels
area: migrations Issues related to `ng update` migrations freq1: low regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Milestone

Comments

@elvisbegovic
Copy link
Contributor

🐞 bug report

Affected Package

The issue is caused by package @angular/core/schematics/migrations/undecorated-classes-with-di/index.ts#L174

Is this a regression?

no, this migration code appear in v9 only not in v8

Description

Undecorated classes with DI migration not working

🔬 Minimal Reproduction

  1. ng update @angular/core --from 8.0.0 --to 9.0.0 --migrate-only"

🔥 Exception or Error


... all previous migrations ARE OK
** Executing migrations for version 9.0.0-beta of package '@angular/core' **
    ------ Undecorated classes with DI migration ------

    This migration uses the Angular compiler internally and therefore projects that no longer build successfully after the update cannot run the migration. Please ensure there are no AOT compilation errors and
 rerun the migration.. The following project failed: tsconfig.app.json
    
    TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    
    Migration can be rerun with: "ng update @angular/core --from 8.0.0 --to 9.0.0 --migrate-only"
    Successfully migrated all found undecorated classes
    that use dependency injection.
    ----------------------------------------------

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.0-next.9
Node: 12.9.1
OS: win32 x64
Angular: 9.0.0-next.10
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-next.9
@angular-devkit/build-angular     0.900.0-next.9
@angular-devkit/build-optimizer   0.900.0-next.9
@angular-devkit/build-webpack     0.900.0-next.9
@angular-devkit/core              9.0.0-next.9
@angular-devkit/schematics        9.0.0-next.9
@angular/cdk                      9.0.0-next.0
@angular/cli                      9.0.0-next.9
@angular/material                 9.0.0-next.0
@angular/pwa                      0.900.0-next.9
@ngtools/webpack                  9.0.0-next.9
@schematics/angular               9.0.0-next.9
@schematics/update                0.900.0-next.9
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.41.0

Anything else relevant?
tsconfig.app.json
tsconfig.json
rudimentary angular.json
I do not have error on ng serve

When debuging nodejs code --inspect-brk migration run without error (but im not sure it udpate my codebase)

@alan-agius4 alan-agius4 added the area: core Issues related to the framework runtime label Oct 14, 2019
@ngbot ngbot bot added this to the needsTriage milestone Oct 14, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 12, 2019
@alxhub alxhub added regression Indicates than the issue relates to something that worked in a previous version and removed severity3: broken labels Feb 10, 2020
@devversion
Copy link
Member

I just saw this issue. Is this still relevant? We landed various fixes and this issue has been reported before v9 stable has been released.

I'm closing this in the meanwhile. Please feel free to create a new one, or respond here. Thanks!

@wittlock
Copy link

wittlock commented Mar 3, 2020

I've run into this issue trying to upgrade a project created on v8 and upgrading it to v9 running version 9.0.2 IIRC. It was stable for sure as I try to avoid pre-releases for production systems.

@devversion
Copy link
Member

Interesting. Thanks for the quick reply. Do you think you would be able to re-run into this issue? If so, and you would be willing to help, that would be highly appreciated.

I'm specifically looking for simply re-running the update with the latest CLI beta version that includes angular/angular-cli@66b218c. That will give us a full stack trace of the error.

@devversion
Copy link
Member

I'd be also happy to have simple reproduction steps. On my end I did not see this issue surface. I've tested various projects against this migration before v9 landed.

@wittlock
Copy link

wittlock commented Mar 3, 2020

Sure, I'll do another test run with the latest versions and see what I come up with. I'll see if I can figure out some reproduction example as well by stripping the project I'm trying to upgrade but no promises on that.

@wittlock
Copy link

wittlock commented Mar 3, 2020

Just tried migrating again using 9.0.4 and I see there's been some very nice updates to the migration process. It now pointed out the source file with an issue (needed an explicit constructor) and it even added a TODO-comment in the file for me. And then the migration concluded instead of failing and needing to be resumed.

So sometime between the version I tried before and 9.0.4 the error has been replaced with a very helpful message and comment which made resolving it trivial. So while issue was still around in some stable version it's absolutely resolved now for my case at least.

Thanks for the prod to try again with the latest fixes.

@devversion
Copy link
Member

Thanks for trying the migration again! Very appreciated. I'm unsure though what change would have fixed this from stable v9 to the current patch release. I'll keep this closed until someone else jumps in and says that the issue is still present.

@pkozlowski-opensource pkozlowski-opensource added area: migrations Issues related to `ng update` migrations and removed area: core Issues related to the framework runtime labels Mar 6, 2020
@StefanChristou
Copy link

I'm getting this error using ng update. Following the guide going from 8-9. Doesn't like my tsconfig.app.json

{ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "types": [] }, "files": [ "main.ts", "polyfills.ts" ], "include": [ "src/**/*.d.ts" ] }

@devversion
Copy link
Member

@StefanChristou Do you have a full error stack trace? I'm looking for more details: #33143 (comment).

@StefanChristou
Copy link

Error message for above comment is:
` This migration uses the Angular compiler internally and therefore projects that no longer build successfully after the update cannot run the migration. Please ensure there are no AOT compilation errors and rerun the migration. The following project failed: src/tsconfig.app.json

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Could not migrate all undecorated classes that use dependency
injection. Some project targets could not be analyzed due to
TypeScript program failures.

Migration can be rerun with: "ng update @angular/core --migrate-only migration-v9-undecorated-classes-with-di"

Migration completed.
`

Tried re-running: "ng update @angular/core --migrate-only migration-v9-undecorated-classes-with-di"

Looks like I'm missing a property from from src/tsconfig.app.json. But what I wonder??

@StefanChristou
Copy link

Full stack trace

Using package manager: 'npm'
Collecting installed dependencies...
Found 88 dependencies.
** Executing 'migration-v9-undecorated-classes-with-di' of package '@angular/core' **

❯ Undecorated classes with DI migration.
  As of Angular 9, it is no longer supported to use Angular DI on a class that does not have an Angular decorator.
  Read more about this here: https://v9.angular.io/guide/migration-undecorated-classes
    
    This migration uses the Angular compiler internally and therefore projects that no longer build successfully after the update cannot run the migration. Please ensure there are no AOT compilation errors and rerun the migration. The following project failed: src/tsconfig.app.json
    
    TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    
    Could not migrate all undecorated classes that use dependency
    injection. Some project targets could not be analyzed due to
    TypeScript program failures.
    
    Migration can be rerun with: "ng update @angular/core --migrate-only migration-v9-undecorated-classes-with-di"
    
  Migration completed.


Your project has been updated to Angular version 9!
For more info, please see: https://v9.angular.io/guide/updating-to-version-9

@devversion
Copy link
Member

Thanks @StefanChristou. Unfortunately the CLI doesn't print out the full stack trace, but just the error message. We added full-stack trace support in the latest next release of the CLI.

When you get a chance, it would be great to re-run the update with the latest @next CLI version installed, or with --next. angular/angular-cli@66b218c. The full stack trace is then stored in a log file.

Let me know if that is possible. The current error doesn't help determining the root cause. I've spent time looking for potential path calls.

@inbanco
Copy link

inbanco commented Mar 16, 2020

@devversion I have the the same issue as @StefanChristou and have updated the CLI to vnext.
Alas, i can't find the log file... can you point me in the direction please. I can post it here if you need it

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: migrations Issues related to `ng update` migrations freq1: low regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Projects
None yet
Development

No branches or pull requests

9 participants