ngx-auth-firebaseui: Cannot find module '@schematics/angular/utility/json-utils'

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

OS and Version?

Catalina 10.15.7

Versions

Angular CLI: 11.0.2 Node: 14.14.0 OS: darwin x64

Repro steps

From the CLI, enter ng add ngx-auth-firebaseui

The log given by the failure

Installing packages for tooling via npm. Installed packages for tooling via npm. An unhandled exception occurred: Cannot find module ‘@schematics/angular/utility/json-utils’ Require stack:

  • /Users/TDK/angularfire/node_modules/ngx-auth-firebaseui/schematics/helpers/angular/json-utils.js
  • /Users/TDK/angularfire/node_modules/ngx-auth-firebaseui/schematics/helpers/angular/index.js
  • /Users/TDK/angularfire/node_modules/ngx-auth-firebaseui/schematics/helpers/index.js
  • /Users/TDK/angularfire/node_modules/ngx-auth-firebaseui/schematics/ng-add/index.js
  • /Users/TDK/angularfire/node_modules/@angular-devkit/schematics/tools/export-ref.js
  • /Users/TDK/angularfire/node_modules/@angular-devkit/schematics/tools/index.js
  • /Users/TDK/angularfire/node_modules/@angular/cli/utilities/json-schema.js
  • /Users/TDK/angularfire/node_modules/@angular/cli/models/command-runner.js
  • /Users/TDK/angularfire/node_modules/@angular/cli/lib/cli/index.js
  • /Users/TDK/.nvm/versions/node/v14.14.0/lib/node_modules/@angular/cli/lib/init.js
  • /Users/TDK/.nvm/versions/node/v14.14.0/lib/node_modules/@angular/cli/bin/ng See “/private/var/folders/dv/x8kx3wkj0tj08gcq1csnk4jm0000gp/T/ng-fuBnGr/angular-errors.log” for further details.

Desired functionality

I want to install ngx-auth-firebaseui.

Mention any other details that might be useful

First time using this package. I’ll try installing with npm.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 8
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I’m having the same issue

@andresrivero in my personal fork of this repo, I was able to remove the json-utils reference (which worked to remove the main issue), however just as you did, I also ran into the issue of 'Cannot read property ‘defaultProject’ of undefined. Upon further investigation into this I was able to find where the problem was occurring, but not why.

Inside a typescript file: projects\ngx-auth-firebaseui\schematics\ng-add\index.ts there is a function that handles the imports. It’s here where the problem lies.

export function addModuleToImports(options: any): Rule {
  return (host: Tree, context: SchematicContext) => {
    const workspace = getWorkspace(host);
    // @ts-ignore
    const project = getProjectFromWorkspace(workspace, options.project);

    // const x =
    //   `apiKey: 'your-firebase-apiKey',
    //   authDomain: 'your-firebase-authDomain',
    //   databaseURL: 'your-firebase-databaseURL',
    //   projectId: 'your-firebase-projectId',
    //   storageBucket: 'your-firebase-storageBucket',
    //   messagingSenderId: 'your-firebase-messagingSenderId'`;
    const moduleName = `NgxAuthFirebaseUIModule.forRoot(PUT_YOUR_FIREBASE_API_KEY_HERE)`;

    addModuleImportToRootModule(host, moduleName, 'ngx-auth-firebaseui', project);

    context.logger.log('info', `✅️ "${moduleName}" is imported`);

    return host;
  };
}

the function ‘getProjectFromWorkspace()’ is coming from angular, however, it would appear the package it comes from should be considered an internal package and shouldn’t be used incase there are changes.

When I print out the value of ‘project’, I get undefined. So I don’t know where we are supposed to define this project (I tried in the angular.json file, but that didn’t seem to work for me). If no value is provided the method sets a default.

function getProjectFromWorkspace(workspace, projectName = workspace.extensions.defaultProject)

I have no idea how the schematics library is defining the value of defaultProject…but it is clear this is the source of the problem.

When using a different schematics version the output looks different but still gets stuck with a different errror

❯ ng add ngx-auth-firebaseui
Skipping installation: Package already installed
    ✅️ Added "ngx-auth-firebaseui" into dependencies
    ✅️ Added "@angular/animations" into dependencies
    ✅️ Added "@angular/forms" into dependencies
    ✅️ Added "@angular/router" into dependencies
    ✅️ Added "@angular/flex-layout" into dependencies
    ✅️ Added "@angular/fire" into dependencies
    ✅️ Added "firebase" into dependencies
    🔍 Installing packages...
Cannot read property 'defaultProject' of undefined

So this is related to schematics version, I’ve tried 11.0.3/11.0.2/11.0.1 - Same Cannot find module ‘@schematics/angular/utility/json-utils’ Error in all 3 other schematic versions 9/10 gives throws Cannot read property ‘defaultProject’ of undefined