Skip to content
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

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

Open
tdkehoe opened this issue Nov 23, 2020 · 15 comments
Open

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

tdkehoe opened this issue Nov 23, 2020 · 15 comments

Comments

@tdkehoe
Copy link

tdkehoe commented Nov 23, 2020

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.

@chobijaeyu
Copy link

chobijaeyu commented Nov 29, 2020

same error...😭

@AnthonyNahas
Copy link
Owner

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

@chobijaeyu
Copy link

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

@PieterVanZyl-Dev
Copy link

PieterVanZyl-Dev commented Dec 4, 2020

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
Copy link

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
Copy link

robwatt commented Dec 10, 2020

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.

@pbrissaud
Copy link

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
Copy link

robwatt commented Dec 13, 2020

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
Copy link

I'm having the same issue

@andresrivero
Copy link

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
Copy link

robwatt commented Jan 21, 2021

@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
Copy link

@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
Copy link
Owner

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

@AnthonyNahas
Copy link
Owner

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

@robwatt
Copy link

robwatt commented Dec 26, 2022

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants