Reputation: 5066
So i'm facing this weird issue. I have 5 modules with routing modules in my angular app. I'm trying to create a component say in fifth module using the command. In the folder i'm trying to create the component i deleted the routing module so that the closest module is the one in which it should import. It works fine as it finds the closest module but it should not do it when --skip-import flag is present but it does so.
ng g c path/to/component/name --skip-import
But i get the error
Error: More than one module matches. Use skip-import option to skip importing the component into the closest module. More than one module matches. Use skip-import option to skip importing the component into the closest module.
I tried use the --module flag to specify the module but still got the same error. Have used both earlier with success.
In the second case i have 2 modules and tried creating a component it creates successfully but imports to closest module even if the --skip-import
flag is present.
Angular CLI Docs for generating component
Below are the screenshots for the same.
Is it something i'm doing wrong or is it a bug? Struggling with this from almost an hours trying ever if and but with no luck.
Referred these questions already. But no luck
My @angular version details
"dependencies": {
"@angular/animations": "^5.2.10",
"@angular/common": "^5.2.10",
"@angular/compiler": "^5.2.10",
"@angular/core": "^5.2.10",
"@angular/forms": "^5.2.10",
"@angular/http": "^5.2.10",
"@angular/platform-browser": "^5.2.10",
"@angular/platform-browser-dynamic": "^5.2.10",
"@angular/router": "^5.2.10",
"bootstrap": "^4.1.0",
"core-js": "^2.5.5",
"file-saver": "^1.3.8",
"font-awesome": "^4.7.0",
"g": "^2.0.1",
"jquery": "^3.3.1",
"moment": "^2.22.1",
"ng-pick-datetime": "^5.2.4",
"ng-pick-datetime-moment": "^1.0.5",
"ngx-pagination-bootstrap": "^1.5.0",
"ngx-select-dropdown": "^0.2.1",
"ngx-slides": "^1.0.1",
"rxjs": "^5.5.10",
"tether": "^1.4.4",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.2.10",
"@angular/language-service": "^5.2.10",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^6.0.106",
"codelyzer": "^4.0.1",
"gh-pages": "^1.1.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
Upvotes: 3
Views: 8195
Reputation: 5066
Though i'm responding to this a bit late. But here is the solution(s) that can work and the one that worked for me.
npm install
againThe last one solved it for me but others also come handy as have helped other colleagues solve similar issues with either of the first three steps.
Hope this helps :)
Upvotes: 0
Reputation: 41
You should run generate it with this. It will generate the folder and component for you.
ng generate component folder_name --module app
Upvotes: 4