angular-cli: ng g input.mergeMap is not a function

ng g app-shell works on a fresh app but on my project I get the following error but no idea what it means

TypeError: input.mergeMap is not a function
    at Object.callRule (/node_modules/@angular-devkit/schematics/src/rules/call.js:70:18)
    at SchematicImpl.call (/node_modules/@angular-devkit/schematics/src/engine/schematic.js:35:23)
    at Promise (/node_modules/@angular/cli/tasks/schematic-run.js:73:23)
    at new Promise (<anonymous>)
    at Class.run (/node_modules/@angular/cli/tasks/schematic-run.js:72:16)
    at Class.run (/node_modules/@angular/cli/commands/generate.js:152:33)
    at resolve (/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
    at new Promise (<anonymous>)
    at Class.validateAndRun (/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)
    at Promise.resolve.then.then (/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:140:24)

The only thing I can think of is it’s a multi app setup structured like

src
  -- client
      -- app
  -- admin
      -- app
  -- environments

but I’ve tried setting the root and get the same result

ng generate app-shell [ --universal-app universal --root src/client ]

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 21
  • Comments: 41 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I was able to fix installing this locally @angular-devkit/schematics@0.0.40

It seems that if you have @angular/cli installed globally and a different version installed locally it gets broken. I solved the same error removing the cli package that was installed locally with npm remove @angular/cli --save in my project folder.

rm package-lock.json npm install @angular-devkit/schematics@0.0.34 --save-dev

worked for me!

Same happens with ng g component [componentname] or ng g module [modulename]

ng generate module public-library/trial
input.mergeMap is not a function
TypeError: input.mergeMap is not a function
    at Object.callRule (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular-devkit/schematics/src/rules/call.js:70:18)
    at SchematicImpl.call (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular-devkit/schematics/src/engine/schematic.js:35:23)
    at Promise (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular/cli/tasks/schematic-run.js:73:23)
    at new Promise (<anonymous>)
    at Class.run (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular/cli/tasks/schematic-run.js:72:16)
    at Class.run (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular/cli/commands/generate.js:152:33)
    at resolve (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
    at new Promise (<anonymous>)
    at Class.validateAndRun (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)
    at Promise.resolve.then.then (/mnt/d/dev/bereslim/bsm-ui/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:140:24)
ng --version

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.6.0
Node: 8.7.0
OS: linux x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cdk: 5.0.0
@angular/cli: 1.6.0
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material-moment-adapter: 5.0.0
@angular/material: 5.0.0
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
typescript: 2.5.3
webpack: 3.10.0

yarn install

warning @schematics/angular@0.1.10" has incorrect peer dependency "@angular-devkit/schematics@0.0.40".
warning "@schematics/schematics@0.0.10" has incorrect peer dependency "@angular-devkit/schematics@0.0.40".

The versions of Angular Cli and TypeScript (local and global) must be the same. Execute: ng -v tsc -v

Then see the versions in package.json. If they are different, then update them.

Globally

npm remove -g @angular/cli npm remove -g typescript

npm i -g @angular/cli@latest npm i -g typescript@latest

Locally

Delete the directories node_modules and dist of your project.

npm i @angular/cli@latest --save-dev npm i typescript@latest --save-dev npm install

That was working for me.

upgraded below packages and it started working again.’

After upgrading from 4 to 5, I had to delete package-lock.json and run npm install - that fixed the problem.

CLI isn’t compatible with typescript 2.6 or above - so run this.

npm install typescript@'>=2.4.2 <2.6.0

Changing schematics worked for me too but then I get another error saying it needed 0.0.42. So I installed 0.0.42 and then typescript 2.5 and it worked again

Installing rxjs@^5.5.5 on angular/cli worked for me.

Had same problem. Tried all recommendations above. Only deleting node_modules and package-lock.json worked out.

Installing @angular-devkit/schematics@0.0.40 seems to have solved the problem for me. Worked like magic

I had the same issue after upgrading to the @angular/cli 1.6.0 and was able to resolve it using: npm i --save-dev @angular/cli@latest and npm i typescript@latest -g as some others mentioned above.

It seems that if you have @angular/cli installed globally and a different version installed locally it gets broken. I solved the same error removing the cli package that was installed locally with npm remove @angular/cli --save in my project folder.

Both my global and local version are the same.

But… uninstalling the local (project) cli works. 👍

[edit] The other way around => uninstall global and install local project CLI results in the same error. So it seems to be a problem with the local (project) cli