Closed
Closed
Copy link
Description
In Angular 4, whenever I use the CLI to create a component (for example, using this command: "ng g c successAlert"), the app.module.ts file does not generate the correct code - it's as if though the code is written two characters too early. For example, if warningAlert were my last added component:
import { WarningAlertComponent } from './warningAlert/warningAlert.component';
@NgModule({
declarations: [
WarningAlertComponent
]
})
And if I were to execute in the CLI "ng g c successAlert", the app.module.ts file would be updated like so:
import { WarningAlertComponent } from './warningAlert/warningAlert.componen;
import { SuccesAlertComponent } from './success-alert/succes-alert.component't';
@NgModule({
declarations: [
WarningAlertCompone,
SuccessAlertComponentnt
]
})
As you can see, there is an error both in the import line, and in the declarations line. This error with two characters is consistent.
If it's relevant, I'm using Sublime Text 3 and the command is being written into the Glue console.
Reacted by DDeis, Jan and holyfirexx
Metadata
Metadata
Assignees
Labels
No labels
Activity
textbook commentedon Sep 18, 2017
This doesn't happen for me with v1.4.2, even if I also mangle an existing component to use the unconventional formatting shown in your example (i.e.
'./warningAlert/warningAlert.component'rather than'./warning-alert/warning-alert.component').Duh-Rell commentedon Sep 24, 2017
Having the same problem. Downgraded from 1.4.3 to 1.4.0 incrementally and the problem still persists.
Edit: When I created the angular project with ng new my global angular-cli version was 1.2.x. I installed angular-cli version 1.4.3 globally and re-ran ng new. Now when I run ng generate component it creates the proper import statements in app.module.ts
kuncevic commentedon Sep 30, 2017
I have never had such an issue constantly keeping my cli always upgraded with the latest.
@artemdru Did you migrated to 1.4.3 or just created a new app?
If you just create a new app do you have the same problem? Did you try cli
1.4.4?@Duh-Rell @artemdru What is your nodejs and OS versions?
fitness23 commentedon Sep 30, 2017
I'm having the same issue as @artemdru
I'm on Node 8 with Windows 10. My project was originally on Angular 1.2.x and when I upgraded to 1.4.4 I got the same issue. I can resolve it if I create a new project from scratch but it's going to get far too complicated merging everything over. Has a solution been found to this?
janmegert commentedon Apr 10, 2018
Same issue. Two characters of previous import/declaration cut off.
Angular CLI: 1.7.3Node: 8.11.1OS: win32 x64Angular: 5.2.9angular-automatic-lock-bot commentedon Sep 8, 2019
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.