question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ammaarpatel99commented, Dec 23, 2020

I’m having the same issue

1reaction
robwattcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module '@schematics/angular/utility/project'
The problem is schematics module incompatibility. Find out the version of the @schematics/angular.
Read more >
cannot find module '@schematics/angular/utility - You.com
I got past the '@schematics/angular/utility/parse-name' error by following the recommended steps. But now I get this error: [error] Error: Cannot find module '@ ......
Read more >
Cannot find module '@schematics/angular/utility/json-utils'
Cannot find module '@schematics/angular/utility/json-utils'
Read more >
schematics-utilities
ℹ️️ Description. At the moment, none of the utilities from the Angular Schematics package are exported. This project was created from that purpose...
Read more >
Facing Issue with Angular Universal Implemetation - Reddit
Facing: An unhandled exception occurred: Cannot find module '@schematics/angular/utility/json-utils'. I have already tried installing files, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found