Skip to content

ng generate component mymodule/mycomp fails when project root set deep #8653

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
Red-3 opened this issue Nov 27, 2017 · 7 comments
Closed

ng generate component mymodule/mycomp fails when project root set deep #8653

Red-3 opened this issue Nov 27, 2017 · 7 comments
Labels
needs: investigation Requires some digging to determine if action is needed severity5: regression

Comments

@Red-3
Copy link

Red-3 commented Nov 27, 2017

Versions

Angular CLI: 1.5.2
Node: 8.2.1
OS: linux x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router, tsc-wrapped
@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.2
@angular/flex-layout: 2.0.0-beta.9
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.21
@angular-devkit/schematics: 0.0.37
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.7
typescript: 2.3.4
webpack: 3.8.1

Repro steps

The root of the @angular project in .angular-cli.json is src/main/webapp

  • Step 1 - Navigate to root folder of project
  • Step 2 - ng generate component mymodule/mycomp
  • Step 3 - ng generate component mymodule/mycomp --skip-import

Observed behavior

Step 2

Error: Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.
Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.

Step 3
Component is created in wrong directory. Full path of component is created in root/app, not at root/app (i.e. path is doubled - see below)

src/main/webapp/src/main/webapp/app/mymodule/mycomp.component.scss

Desired behavior

Component created in the correct location and imported into the project module.

Mention any other details that might be useful (optional)

  • I created a new component a couple of weeks ago, but since then I have upgraded several components, including @angular/core, @angular/material and @angular/flex-layout
  • (Project was originally created with JHipster - Java/SpringBoot backend.)
  • To troubleshoot, I created a new project with ng new myproj --source-dir src/main/webapp and it created the component OK. But this project is too complex to create afresh and port code over.
  • BTW - --source-dir option is not documented

FAO: @hansl

@filipesilva filipesilva added needs: investigation Requires some digging to determine if action is needed severity5: regression labels Nov 28, 2017
@jiniguez
Copy link

I had a similar issue in a jHipster generated project but I upgraded Angular CLI from 1.6.0 version to 1.6.1 and it seems to be working fine now.

Version 1.6.0

$ ng generate component mymodule/mycomp --skip-import -d
Your global Angular CLI version (1.6.1) is greater than your local
version (1.6.0). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
  create src/main/webapp/src/main/webapp/app/mymodule/mycomp/mycomp.component.html (25 bytes)
  create src/main/webapp/src/main/webapp/app/mymodule/mycomp/mycomp.component.ts (242 bytes)

NOTE: Run with "dry run" no changes were made.

Version 1.6.1

$ ng generate component mymodule/mycomp --skip-import -d
  create src/main/webapp/app/mymodule/mycomp/mycomp.component.html (25 bytes)
  create src/main/webapp/app/mymodule/mycomp/mycomp.component.ts (242 bytes)

NOTE: Run with "dry run" no changes were made.

Can you take a look too, @Red-3 ?

@Red-3
Copy link
Author

Red-3 commented Jan 2, 2018

I'm now on version 1.6.2, still no joy...

$ ng generate component signup/newcomponent --skip-import -d
input.mergeMap is not a function
TypeError: input.mergeMap is not a function
    at Object.callRule (/home/abiggs/git/wonderville/node_modules/@angular-devkit/schematics/src/rules/call.js:78:18)
    at SchematicImpl.call (/home/abiggs/git/wonderville/node_modules/@angular-devkit/schematics/src/engine/schematic.js:35:23)
    at Promise (/home/abiggs/git/wonderville/node_modules/@angular/cli/tasks/schematic-run.js:73:23)
    at Promise (<anonymous>)
    at Class.run (/home/abiggs/git/wonderville/node_modules/@angular/cli/tasks/schematic-run.js:72:16)
    at Class.run (/home/abiggs/git/wonderville/node_modules/@angular/cli/commands/generate.js:161:33)
    at resolve (/home/abiggs/git/wonderville/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
    at Promise (<anonymous>)
    at Class.validateAndRun (/home/abiggs/git/wonderville/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)
    at Promise.resolve.then.then (/home/abiggs/git/wonderville/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:140:24)

@Brocco
Copy link
Contributor

Brocco commented Jan 8, 2018

Based upon my findings input.mergeMap is not a function is a result of different versions of rxjs being installed. This will be resolved by updating both the CLI and devkit repos to use "lettable" operators.

PRs:
CLI: #8976
devkit: angular/devkit#345

@hansl hansl unassigned Brocco Feb 6, 2018
@ved1995
Copy link

ved1995 commented Jun 10, 2018

if You are using Angular 6 then change your current directory to /src/app/ then use ng g c new-component. I think the problem will be resolved, It works for me.

@macsompo
Copy link

if "ng" is serving the project ..you can probably get this error also....i canceled ng serve in terminal . and it worked

@alan-agius4
Copy link
Collaborator

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation Requires some digging to determine if action is needed severity5: regression
Projects
None yet
Development

No branches or pull requests

7 participants