Search code examples
angularngx-bootstrapangular17

Could not find the project main file inside of the workspace config (src)


I started a personal project that using angular 17 in front-side and decided to use ngx-bootstrap. Ngx-bootstrap released a version([email protected]) compatible with angular 17. But I got an error that says "Could not find the project main file inside of the workspace config (src)" when downloading ngx-bootstrap.

$ ng add ngx-bootstrap
ℹ 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.
    ✅️ Added "bootstrap
    ✅️ Added "ngx-bootstrap
Could not find the project main file inside of the workspace config (src)

folder structure

I tried to download again but got same error.


Solution

  • An issue has already been created on ngx-bootstrap github page So you can just use ng-bootstrap as per their suggestion which actually works great!

    This is the code that breaks the command. It seems to expect app.module instead of main.ts

    export function getProjectMainFile(project: workspaces.ProjectDefinition): string {
      const buildOptions = getProjectTargetOptions(project, 'build');
      if (!buildOptions.main) {
        throw new SchematicsException(`Could not find the project main file inside of the ` +
          `workspace config (${project.sourceRoot})`);
      }
    
      return buildOptions.main.toString();
    }
    

    If you really want ngx-bootstrap only, then you need to install it manually. Here is the installation guide.