You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"ng generate module/component" doesn't work as expected #5127
I tried to repo your issue and I can confirm it happens on projects running cli RC0, I first tested on Beta.29 this issue was not present.
For your last 2 points, it sounds like it's more of a new feature request to support adding components to specific modules. The thing is that the cli is in RC now which means no new features will be added until 2.0
I'll have a look through the recent PR on module creation to see what can be causing the routing issue.
I'm not entirely sure that it is a new feature since I was under the impression that the new components will/should be added to the nearest module.
But okay, we can achieve that in this case with ng g c my-module/my-module --flat for now. Feels a bit hacky though.
I'm having this issue, too. All new components are being added not to the nearest module, but to the root app.module. This is not a new feature....but it does appear to be broken. I can confirm that @bboehm86 suggestion of my-module/my-module --flat does produce the desired outcome of generating a component and having the CLI add it to the module in that director.
After generating a new module ng g module home the command ng g component home --module=home produces the following error:
Error: EISDIR: illegal operation on a directory, read
at Object.fs.readSync (fs.js:656:19)
at tryReadSync (fs.js:457:20)
at Object.fs.readFileSync (fs.js:494:19)
at Class.afterInstall (C:\Users\Nella\Documents\GitHub\pccRegistration\node_modules\@angular\cli\blueprints\component\index.js:207:34)
at tryCatch (C:\Users\Nella\Documents\GitHub\pccRegistration\node_modules\rsvp\dist\rsvp.js:538:12)
at invokeCallback (C:\Users\Nella\Documents\GitHub\pccRegistration\node_modules\rsvp\dist\rsvp.js:553:13)
at publish (C:\Users\Nella\Documents\GitHub\pccRegistration\node_modules\rsvp\dist\rsvp.js:521:7)
at flush (C:\Users\Nella\Documents\GitHub\pccRegistration\node_modules\rsvp\dist\rsvp.js:2373:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
$ ng g module back --routing
installing module
create src\app\back\back-routing.module.ts
create src\app\back\back.module.ts
$ ng g component back\home --module back
installing component
create src\app\back\home\home.component.sass
create src\app\back\home\home.component.html
create src\app\back\home\home.component.spec.ts
create src\app\back\home\home.component.ts
EISDIR: illegal operation on a directory, read
Error: EISDIR: illegal operation on a directory, read
at Error (native)
at Object.fs.readSync (fs.js:731:19)
at tryReadSync (fs.js:486:20)
at Object.fs.readFileSync (fs.js:534:19)
at Class.afterInstall (C:\Users\alvaro\Desktop\testing\node_modules\@angular\cli\blueprints\component\index.js:190:34)
at tryCatch (C:\Users\alvaro\Desktop\testing\node_modules\rsvp\dist\rsvp.js:538:12)
at invokeCallback (C:\Users\alvaro\Desktop\testing\node_modules\rsvp\dist\rsvp.js:553:13)
at publish (C:\Users\alvaro\Desktop\testing\node_modules\rsvp\dist\rsvp.js:521:7)
at flush (C:\Users\alvaro\Desktop\testing\node_modules\rsvp\dist\rsvp.js:2373:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
The result is the expected unless the new component is not included in the module structure. In other words, the module does not declare the new component.
@bboehm86, The issue is that by not specifying --flat the CLI thinks that it is going to create a folder and begin looking in the parent folder to that component. Part of me wants to say this is the correct functionality.
@markgoho and @AlvaroOrduna, you will need to be more specific on the file you wish to use for your module.
@markgoho: ng g component home --module=home/home.module
@AlvaroOrduna: ng g component back\home --module back\back.module
That said, I'll look into creating a PR for both of these issues. I'll let the CLI team determine what the correct functionality is.
Side note: I incorrectly thought my other PR, #5218, fixed this issue. It does not.
ERROR in C:/wamp64/www/p-page/src/app/app.module.ts (5,30): Cannot find module './src/app/cp1/cp1.component'.
ERROR in C:/wamp64/www/p-page/src/app/app.module.ts (5,30): Cannot find module './src/app/cp1/cp1.component'.
ERROR in ./app.module.ts
Module not found: Error: Can't resolve './src/app/cp1/cp1.component' in 'C:\wamp64\www\p-page\src\app'
@ ./app.module.ts 10:0-59
@ ../main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ../main.ts
webpack: Failed to compile.
Activity
RicardoVaranda commentedon Mar 1, 2017
Hi @bboehm86 ,
I tried to repo your issue and I can confirm it happens on projects running cli RC0, I first tested on Beta.29 this issue was not present.
For your last 2 points, it sounds like it's more of a new feature request to support adding components to specific modules. The thing is that the cli is in RC now which means no new features will be added until 2.0
I'll have a look through the recent PR on module creation to see what can be causing the routing issue.
bboehm86 commentedon Mar 1, 2017
Hey @RicardoVaranda ,
thanks for having a look. 👍
I'm not entirely sure that it is a new feature since I was under the impression that the new components will/should be added to the nearest module.
But okay, we can achieve that in this case with
ng g c my-module/my-module --flatfor now. Feels a bit hacky though.markgoho commentedon Mar 1, 2017
I'm having this issue, too. All new components are being added not to the nearest module, but to the root app.module. This is not a new feature....but it does appear to be broken. I can confirm that @bboehm86 suggestion of
my-module/my-module --flatdoes produce the desired outcome of generating a component and having the CLI add it to the module in that director.After generating a new module
ng g module homethe commandng g component home --module=homeproduces the following error:filipesilva commentedon Mar 2, 2017
@Brocco can you weigh in?
filipesilva commentedon Mar 2, 2017
Partially dupe of #4614
alorle commentedon Mar 3, 2017
Same here:
Steps:
The result is the expected unless the new component is not included in the module structure. In other words, the module does not declare the new component.
fix(@angular/cli): fix issue with console prompt bailing early
fix(@angular/cli): fix issue with console prompt bailing early
delasteve commentedon Mar 4, 2017
@bboehm86, The issue is that by not specifying
--flatthe CLI thinks that it is going to create a folder and begin looking in the parent folder to that component. Part of me wants to say this is the correct functionality.@markgoho and @AlvaroOrduna, you will need to be more specific on the file you wish to use for your module.
@markgoho:
ng g component home --module=home/home.module@AlvaroOrduna:
ng g component back\home --module back\back.moduleThat said, I'll look into creating a PR for both of these issues. I'll let the CLI team determine what the correct functionality is.
Side note: I incorrectly thought my other PR, #5218, fixed this issue. It does not.
fix(@angular/cli): fix component not finding closest module
fix(@angular/cli): fix component not finding closest module
fix(@angular/cli): fix component not finding closest module
Brocco commentedon Mar 6, 2017
Closing this one in favor of tracking it via #4614
fix(@angular/cli): fix component not finding closest module
fix(@angular/cli): fix declarable types not finding closest module
fix(@angular/cli): fix issue with console prompt bailing early (#5218)
fix(@angular/cli): fix issue with console prompt bailing early (angul…
tiagocaetano commentedon Aug 5, 2017
I have same issue , when i try to generate the component, the cmd didn't create the files and the folder, inside the project.
ERROR in C:/wamp64/www/p-page/src/app/app.module.ts (5,30): Cannot find module './app/cp1/cp1.component'.
ERROR in ./app.module.ts
Module not found: Error: Can't resolve './app/cp1/cp1.component' in 'C:\wamp64\www\p-page\src\app'
@ ./app.module.ts 10:0-55
@ ../main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ../main.ts
webpack: Failed to compile.
webpack: Compiling...
Hash: b46038d9bcc98a16a342
Time: 2868ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 177 kB {4} [initial]
chunk {1} main.bundle.js, main.bundle.js.map (main) 5.44 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.19 MB [initial]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]
ERROR in C:/wamp64/www/p-page/src/app/app.module.ts (5,30): Cannot find module './src/app/cp1/cp1.component'.
ERROR in C:/wamp64/www/p-page/src/app/app.module.ts (5,30): Cannot find module './src/app/cp1/cp1.component'.
ERROR in ./app.module.ts
Module not found: Error: Can't resolve './src/app/cp1/cp1.component' in 'C:\wamp64\www\p-page\src\app'
@ ./app.module.ts 10:0-59
@ ../main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ../main.ts
webpack: Failed to compile.
@angular/cli: 1.2.7
node: 6.10.2
os: win32 x64
@angular/animations: 4.3.3
@angular/common: 4.3.3
@angular/compiler: 4.3.3
@angular/core: 4.3.3
@angular/forms: 4.3.3
@angular/http: 4.3.3
@angular/platform-browser: 4.3.3
@angular/platform-browser-dynamic: 4.3.3
@angular/router: 4.3.3
@angular/cli: 1.2.7
@angular/compiler-cli: 4.3.3
@angular/language-service: 4.3.3
C:\wamp64\www\p-page\src\app>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
How i can fix this ...
angular-automatic-lock-bot commentedon Sep 7, 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.
fix(@angular/cli): fix issue with console prompt bailing early (angul…