Skip to content

ng generate in a sub directory adds a backslash to the app.module import statement #2388

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
NiklasTeich opened this issue Sep 28, 2016 · 4 comments

Comments

@NiklasTeich
Copy link

NiklasTeich commented Sep 28, 2016

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Windows 7

  1. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.15
node: 6.3.0
os: win32 x64

  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.

"ng generate component" in a sub directory adds a backslash in the app.module.ts import statement.
For example, app/settings component exists, after "ng generate component users" in the settings directory, the app.module has this statement:
"import { UsersComponent } from './settings\users/users.component';"

ng serve crashes, after changing the backslash to a normal slash, ng serve builds everything and the app works like expected!

  1. The log given by the failure. Normally this include a stack trace and some
    more information.

Bad character escape sequence (24:44)
You may need an appropriate loader to handle this file type.
| import { DashboardComponent } from './dashboard/dashboard.component';
| import { SettingsComponent } from './settings/settings.component';
| import { UsersComponent } from './settings\users/users.component';
| export var AppModule = (function () {
| function AppModule() {
@ ./src/app/index.ts 2:0-29
@ ./src/main.ts
@ multi main

@celliott181
Copy link
Contributor

celliott181 commented Sep 29, 2016

Seems like part of a known issue. See #2132 and #2357.

This has to do with the OS level directory separators, and the workaround is to generate components from the root using the proper slash to match your OS.

@NiklasTeich
Copy link
Author

Thanks, good idea!
Another open (same addressed) issue is here: #2419

@filipesilva
Copy link
Contributor

Dupe of #1719, already fixed.

@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 Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants