AnthonyNahas / ngx-auth-firebaseui

Angular Material UI component for firebase authentication
https://ngx-auth-firebaseui.firebaseapp.com
MIT License
587 stars 165 forks source link

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

Open tdkehoe opened 3 years ago

tdkehoe commented 3 years ago

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:

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.

chobijaeyu commented 3 years ago

same error...😭

AnthonyNahas commented 3 years ago

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

chobijaeyu commented 3 years ago

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


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

PieterVanZyl-Dev commented 3 years ago

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 commented 3 years ago

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

robwatt commented 3 years ago

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.

pbrissaud commented 3 years ago

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
robwatt commented 3 years ago

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.

ammaarpatel99 commented 3 years ago

I'm having the same issue

andresrivero commented 3 years ago

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

robwatt commented 3 years ago

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

andresrivero commented 3 years ago

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

AnthonyNahas commented 3 years ago

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

AnthonyNahas commented 1 year ago

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

robwatt commented 1 year ago

@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: ngx-auth-firebaseui@7.1.0. ✔ Package information loaded.

The package ngx-auth-firebaseui@7.1.0 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