angularnrwl

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


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.

Environment:

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.


Solution

  • 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.