ngx-auth-firebaseui icon indicating copy to clipboard operation
ngx-auth-firebaseui copied to clipboard

Cannot find module '@schematics/angular/utility/json-utils'

Open tdkehoe opened this issue 4 years ago • 15 comments

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.

tdkehoe avatar Nov 23 '20 16:11 tdkehoe

same error...😭

chobijaeyu avatar Nov 29 '20 02:11 chobijaeyu

which version of @angular-devkit/schematics/ are you installing ?

AnthonyNahas avatar Nov 30 '20 20:11 AnthonyNahas

which version of @angular-devkit/schematics/ are you installing ? "@angular-devkit/[email protected]":

Angular CLI: 11.0.2
Node: 15.3.0
OS: darwin x64

Angular: 11.0.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.2
@angular-devkit/build-angular   0.1100.2
@angular-devkit/core            11.0.2
@angular-devkit/schematics      11.0.2
@angular/cdk                    11.0.1
@angular/fire                   6.1.2
@angular/flex-layout            11.0.0-beta.33
@angular/material               11.0.1
@schematics/angular             11.0.2
@schematics/update              0.1100.2
rxjs                            6.6.3
typescript                      4.0.5

chobijaeyu avatar Dec 01 '20 21:12 chobijaeyu

I would like to confirm that I am getting this exact same error. I thought it might be nvm related so I installed node and disabled nvm but that didn't solve the problem.

Installing via npm isn't an option for me as I plan on changing the things like the user profile page to match my requirements.

Angular CLI: 11.0.3
Node: 14.15.1
OS: win32 x64

Angular: 11.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.3
@angular-devkit/build-angular   0.1100.3
@angular-devkit/core            11.0.3
@angular-devkit/schematics      11.0.3
@angular/cdk                    11.0.1
@angular/fire                   6.1.4
@angular/flex-layout            11.0.0-beta.33
@angular/material               11.0.1
@schematics/angular             11.0.3
@schematics/update              0.1100.3
rxjs                            6.6.3
typescript                      4.0.5

Is my version information.

PieterVanZyl-Dev avatar Dec 04 '20 07:12 PieterVanZyl-Dev

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

PieterVanZyl-Dev avatar Dec 04 '20 07:12 PieterVanZyl-Dev

I want to use this library as well, so I did some digging. Turns out the folks over on the angular/cli repo actually deleted the files. Here is the PR: https://github.com/angular/angular-cli/pull/18875

Given the merge date of Sept 24th, it was probably merged into one of the 11.0 pre-release builds. Which means you would need to use angular/cli 10.x in order for this library to continue to work.

robwatt avatar Dec 10 '20 04:12 robwatt

Same issue with Ubuntu 20.04 LTS and schematics 11.0.4. Wanted to use this library which looks super cool !

ng version output :


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 11.0.4
Node: 14.15.1
OS: linux x64

Angular: 11.0.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.4
@angular-devkit/build-angular   0.1100.4
@angular-devkit/core            11.0.4
@angular-devkit/schematics      11.0.4
@angular/cdk                    11.0.2
@angular/fire                   6.1.4
@angular/material               11.0.2
@schematics/angular             11.0.4
@schematics/update              0.1100.4
rxjs                            6.6.3
typescript                      4.0.5

pbrissaud avatar Dec 12 '20 19:12 pbrissaud

This library creates a wrapper around json-utils.ts. Since that file has now been deleted from the schematics/angular library. Can it be deleted from this library as well? I looked into the code and as far as I can tell it is not being used by anything.

Minimal steps would be to increase the dependency of schematics/angular from 9.x to 11.0.x and then delete the file.

robwatt avatar Dec 13 '20 23:12 robwatt

I'm having the same issue

ammaarpatel99 avatar Dec 23 '20 22:12 ammaarpatel99

I want to use this library as well, so I did some digging. Turns out the folks over on the angular/cli repo actually deleted the files. Here is the PR: angular/angular-cli#18875

Given the merge date of Sept 24th, it was probably merged into one of the 11.0 pre-release builds. Which means you would need to use angular/cli 10.x in order for this library to continue to work.

I tried with @angular/cli & @schematics/angular versions of 10.2.1 and it was able to progress to the "Installing packages..." portion but then it fails with "Cannot read property 'defaultProject' of undefined

andresrivero avatar Jan 17 '21 04:01 andresrivero

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

robwatt avatar Jan 21 '21 01:01 robwatt

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

I just used the forced npm install of each package to bypass the error for now, if I have a moment maybe I can follow your direction and see how the project name issue can be fixed.

andresrivero avatar Jan 22 '21 01:01 andresrivero

Does someone have the time to improve that via an appropriate PR ?

AnthonyNahas avatar Mar 31 '21 19:03 AnthonyNahas

Can someone test the schematics with the latest version, please?

AnthonyNahas avatar Nov 13 '22 11:11 AnthonyNahas

@AnthonyNahas , I ran a clean test using the following Angular 14 Angular Material 14

Here are the commands I ran to get the below output

npm i -g @angular/cli@14
ng new fb-test (added routing and scss)
cd fb-test
ng add @angular/material (this wants to install v13)
npm i @angular/cdk@14 @angular/material@14
ng add ngx-auth-firebaseui

I get the following output when I try to install ngx-auth-firebaseui

` ng add ngx-auth-firebaseui ℹ Using package manager: npm ✔ Found compatible package version: [email protected]. ✔ Package information loaded.

The package [email protected] will be installed and executed. Would you like to proceed? Yes ✔ Packages successfully installed. Package subpath './schematics/ng-add/package-config' is not defined by "exports" in I:\dev\fb-test\node_modules@angular\cdk\package.json `

Not sure what the error means...but I believe all further steps are halted. According to your instructions about what should happen when installing...the below did NOT happen

  • peer dependencies will be automatically added the package.json and installed
  • ngx-auth-firebaseui 's module will be automatically imported to the root module (just replace PUT_YOUR_FIREBASE_API_KEY_HERE with your firebase api key)
  • ngx-auth-firebaseui 's assets will be automatically added the angular.json file

robwatt avatar Dec 26 '22 15:12 robwatt