Could not find an NgModule. Use the skip-import option to skip importing in NgModule











up vote
6
down vote

favorite
1












I get the error in the subject of this post when I use the CLI to create a new component: ng g c my-component --project=my-project (No component is created)



I've seen other posts with the same error message, but none of them also include Nrwl/Nx, which I believe is somehow involved. Project started as Ng4 and was upgraded to Ng6.



Any ideas how I can fix this?



Thx.



TTE



Environment:




  • Angular CLI: 6.0.8

  • Node: 8.9.4

  • OS: win32 x64

  • Angular: 6.0.6

  • @angular-devkit/architect 0.6.8

  • @angular-devkit/build-angular 0.6.8

  • @angular-devkit/build-optimizer 0.6.8

  • @angular-devkit/core 0.6.8

  • @angular-devkit/schematics 0.6.8

  • @angular/cdk 6.3.1

  • @angular/cli 6.0.8

  • @angular/material 6.3.1

  • @ngtools/webpack 6.0.8

  • @schematics/angular 0.6.1

  • @schematics/update 0.6.8

  • rxjs 6.2.1

  • typescript 2.7.2

  • webpack 4.8.3

  • nrwl/nx 6.1.0


UPDATE #1



I tried dropping the --project flag entirely ( so just ng g c my-component) and still get the same problem. Not sure what that means, yet.










share|improve this question




























    up vote
    6
    down vote

    favorite
    1












    I get the error in the subject of this post when I use the CLI to create a new component: ng g c my-component --project=my-project (No component is created)



    I've seen other posts with the same error message, but none of them also include Nrwl/Nx, which I believe is somehow involved. Project started as Ng4 and was upgraded to Ng6.



    Any ideas how I can fix this?



    Thx.



    TTE



    Environment:




    • Angular CLI: 6.0.8

    • Node: 8.9.4

    • OS: win32 x64

    • Angular: 6.0.6

    • @angular-devkit/architect 0.6.8

    • @angular-devkit/build-angular 0.6.8

    • @angular-devkit/build-optimizer 0.6.8

    • @angular-devkit/core 0.6.8

    • @angular-devkit/schematics 0.6.8

    • @angular/cdk 6.3.1

    • @angular/cli 6.0.8

    • @angular/material 6.3.1

    • @ngtools/webpack 6.0.8

    • @schematics/angular 0.6.1

    • @schematics/update 0.6.8

    • rxjs 6.2.1

    • typescript 2.7.2

    • webpack 4.8.3

    • nrwl/nx 6.1.0


    UPDATE #1



    I tried dropping the --project flag entirely ( so just ng g c my-component) and still get the same problem. Not sure what that means, yet.










    share|improve this question


























      up vote
      6
      down vote

      favorite
      1









      up vote
      6
      down vote

      favorite
      1






      1





      I get the error in the subject of this post when I use the CLI to create a new component: ng g c my-component --project=my-project (No component is created)



      I've seen other posts with the same error message, but none of them also include Nrwl/Nx, which I believe is somehow involved. Project started as Ng4 and was upgraded to Ng6.



      Any ideas how I can fix this?



      Thx.



      TTE



      Environment:




      • Angular CLI: 6.0.8

      • Node: 8.9.4

      • OS: win32 x64

      • Angular: 6.0.6

      • @angular-devkit/architect 0.6.8

      • @angular-devkit/build-angular 0.6.8

      • @angular-devkit/build-optimizer 0.6.8

      • @angular-devkit/core 0.6.8

      • @angular-devkit/schematics 0.6.8

      • @angular/cdk 6.3.1

      • @angular/cli 6.0.8

      • @angular/material 6.3.1

      • @ngtools/webpack 6.0.8

      • @schematics/angular 0.6.1

      • @schematics/update 0.6.8

      • rxjs 6.2.1

      • typescript 2.7.2

      • webpack 4.8.3

      • nrwl/nx 6.1.0


      UPDATE #1



      I tried dropping the --project flag entirely ( so just ng g c my-component) and still get the same problem. Not sure what that means, yet.










      share|improve this question















      I get the error in the subject of this post when I use the CLI to create a new component: ng g c my-component --project=my-project (No component is created)



      I've seen other posts with the same error message, but none of them also include Nrwl/Nx, which I believe is somehow involved. Project started as Ng4 and was upgraded to Ng6.



      Any ideas how I can fix this?



      Thx.



      TTE



      Environment:




      • Angular CLI: 6.0.8

      • Node: 8.9.4

      • OS: win32 x64

      • Angular: 6.0.6

      • @angular-devkit/architect 0.6.8

      • @angular-devkit/build-angular 0.6.8

      • @angular-devkit/build-optimizer 0.6.8

      • @angular-devkit/core 0.6.8

      • @angular-devkit/schematics 0.6.8

      • @angular/cdk 6.3.1

      • @angular/cli 6.0.8

      • @angular/material 6.3.1

      • @ngtools/webpack 6.0.8

      • @schematics/angular 0.6.1

      • @schematics/update 0.6.8

      • rxjs 6.2.1

      • typescript 2.7.2

      • webpack 4.8.3

      • nrwl/nx 6.1.0


      UPDATE #1



      I tried dropping the --project flag entirely ( so just ng g c my-component) and still get the same problem. Not sure what that means, yet.







      angular nrwl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 5 at 23:44

























      asked Jul 5 at 22:57









      TimTheEnchanter

      825517




      825517
























          4 Answers
          4






          active

          oldest

          votes

















          up vote
          17
          down vote













          Quick fix



          1) Change current directory in cmd/terminal to src/app



          cd src/app (linux)



          cd .srcapp (windows)



          2) Run commands now



          ng g c myComponent






          share|improve this answer

















          • 1




            Doesn't work in nrwl/nx environment
            – TimTheEnchanter
            Aug 14 at 17:51










          • Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
            – Debojyoti
            Aug 26 at 16:48








          • 1




            The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
            – carkod
            Nov 11 at 3:57




















          up vote
          0
          down vote



          accepted










          I ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:



          "root": "libs/my-lib",
          "sourceRoot": "libs/my-lib/src"


          I'm not sure which of those fixed the problem, but all appears to be OK now. At least the immediate problem went away.



          Hopefully this helps someone else.



          TTE






          share|improve this answer




























            up vote
            0
            down vote













            Had same issue. Turned out to be somehow related to the name of the root component. Renaming back to 'app' resolved the problem






            share|improve this answer




























              up vote
              0
              down vote













              I had the same issue, In angular.json file, I searched for my-project-e2e (replace my-project with your project name)
              and then I changed:



              "root": "" to "root": "e2e"
              and saved it. Everything was working again.



              The solution was specified in this link.






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51200919%2fcould-not-find-an-ngmodule-use-the-skip-import-option-to-skip-importing-in-ngmo%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                17
                down vote













                Quick fix



                1) Change current directory in cmd/terminal to src/app



                cd src/app (linux)



                cd .srcapp (windows)



                2) Run commands now



                ng g c myComponent






                share|improve this answer

















                • 1




                  Doesn't work in nrwl/nx environment
                  – TimTheEnchanter
                  Aug 14 at 17:51










                • Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
                  – Debojyoti
                  Aug 26 at 16:48








                • 1




                  The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
                  – carkod
                  Nov 11 at 3:57

















                up vote
                17
                down vote













                Quick fix



                1) Change current directory in cmd/terminal to src/app



                cd src/app (linux)



                cd .srcapp (windows)



                2) Run commands now



                ng g c myComponent






                share|improve this answer

















                • 1




                  Doesn't work in nrwl/nx environment
                  – TimTheEnchanter
                  Aug 14 at 17:51










                • Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
                  – Debojyoti
                  Aug 26 at 16:48








                • 1




                  The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
                  – carkod
                  Nov 11 at 3:57















                up vote
                17
                down vote










                up vote
                17
                down vote









                Quick fix



                1) Change current directory in cmd/terminal to src/app



                cd src/app (linux)



                cd .srcapp (windows)



                2) Run commands now



                ng g c myComponent






                share|improve this answer












                Quick fix



                1) Change current directory in cmd/terminal to src/app



                cd src/app (linux)



                cd .srcapp (windows)



                2) Run commands now



                ng g c myComponent







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 12 at 4:47









                Debojyoti

                892515




                892515








                • 1




                  Doesn't work in nrwl/nx environment
                  – TimTheEnchanter
                  Aug 14 at 17:51










                • Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
                  – Debojyoti
                  Aug 26 at 16:48








                • 1




                  The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
                  – carkod
                  Nov 11 at 3:57
















                • 1




                  Doesn't work in nrwl/nx environment
                  – TimTheEnchanter
                  Aug 14 at 17:51










                • Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
                  – Debojyoti
                  Aug 26 at 16:48








                • 1




                  The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
                  – carkod
                  Nov 11 at 3:57










                1




                1




                Doesn't work in nrwl/nx environment
                – TimTheEnchanter
                Aug 14 at 17:51




                Doesn't work in nrwl/nx environment
                – TimTheEnchanter
                Aug 14 at 17:51












                Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
                – Debojyoti
                Aug 26 at 16:48






                Thanks @TimTheEnchanter for pointing out. Yeah it's a fix for normal usage of angular cli.
                – Debojyoti
                Aug 26 at 16:48






                1




                1




                The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
                – carkod
                Nov 11 at 3:57






                The reason why this works, is that your project's default src/app folder hierarchy has been changed. Therefore, anything else that doesn't fit this situation will not work. When you generate a default project with cli, you shouldn't have to do this.
                – carkod
                Nov 11 at 3:57














                up vote
                0
                down vote



                accepted










                I ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:



                "root": "libs/my-lib",
                "sourceRoot": "libs/my-lib/src"


                I'm not sure which of those fixed the problem, but all appears to be OK now. At least the immediate problem went away.



                Hopefully this helps someone else.



                TTE






                share|improve this answer

























                  up vote
                  0
                  down vote



                  accepted










                  I ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:



                  "root": "libs/my-lib",
                  "sourceRoot": "libs/my-lib/src"


                  I'm not sure which of those fixed the problem, but all appears to be OK now. At least the immediate problem went away.



                  Hopefully this helps someone else.



                  TTE






                  share|improve this answer























                    up vote
                    0
                    down vote



                    accepted







                    up vote
                    0
                    down vote



                    accepted






                    I ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:



                    "root": "libs/my-lib",
                    "sourceRoot": "libs/my-lib/src"


                    I'm not sure which of those fixed the problem, but all appears to be OK now. At least the immediate problem went away.



                    Hopefully this helps someone else.



                    TTE






                    share|improve this answer












                    I ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:



                    "root": "libs/my-lib",
                    "sourceRoot": "libs/my-lib/src"


                    I'm not sure which of those fixed the problem, but all appears to be OK now. At least the immediate problem went away.



                    Hopefully this helps someone else.



                    TTE







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 9 at 15:11









                    TimTheEnchanter

                    825517




                    825517






















                        up vote
                        0
                        down vote













                        Had same issue. Turned out to be somehow related to the name of the root component. Renaming back to 'app' resolved the problem






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          Had same issue. Turned out to be somehow related to the name of the root component. Renaming back to 'app' resolved the problem






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Had same issue. Turned out to be somehow related to the name of the root component. Renaming back to 'app' resolved the problem






                            share|improve this answer












                            Had same issue. Turned out to be somehow related to the name of the root component. Renaming back to 'app' resolved the problem







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 5 at 4:21









                            Aleksei Protopopov

                            1




                            1






















                                up vote
                                0
                                down vote













                                I had the same issue, In angular.json file, I searched for my-project-e2e (replace my-project with your project name)
                                and then I changed:



                                "root": "" to "root": "e2e"
                                and saved it. Everything was working again.



                                The solution was specified in this link.






                                share|improve this answer



























                                  up vote
                                  0
                                  down vote













                                  I had the same issue, In angular.json file, I searched for my-project-e2e (replace my-project with your project name)
                                  and then I changed:



                                  "root": "" to "root": "e2e"
                                  and saved it. Everything was working again.



                                  The solution was specified in this link.






                                  share|improve this answer

























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    I had the same issue, In angular.json file, I searched for my-project-e2e (replace my-project with your project name)
                                    and then I changed:



                                    "root": "" to "root": "e2e"
                                    and saved it. Everything was working again.



                                    The solution was specified in this link.






                                    share|improve this answer














                                    I had the same issue, In angular.json file, I searched for my-project-e2e (replace my-project with your project name)
                                    and then I changed:



                                    "root": "" to "root": "e2e"
                                    and saved it. Everything was working again.



                                    The solution was specified in this link.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Nov 11 at 11:19









                                    carkod

                                    149113




                                    149113










                                    answered Aug 8 at 16:25









                                    lanchana gupta

                                    6617




                                    6617






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51200919%2fcould-not-find-an-ngmodule-use-the-skip-import-option-to-skip-importing-in-ngmo%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Xamarin.iOS Cant Deploy on Iphone

                                        Glorious Revolution

                                        Dulmage-Mendelsohn matrix decomposition in Python