Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Universal "Module file (/src/app/.ts) not found"

I have an app originally developed on Angular 2 that I have slowly migrated over time as new versions of Angular come out using Angular release documentations. Currently the version of the angular in the app is: 7.2.15

I should also add that I have moved my NestJs + Angular projects into a mono repo using: @nrwl/nx, but even trying to add universal to my previous versioin with no @nrwl/nx mono-repo is giving the same error

Now when I try to add angular universal support:

ng add @nguniversal/express-engine --clientProject <my project name>

I am getting the following error:

Module file (/src/app/.ts) not found

This is the only error I am getting, making it very difficult to know where to start. I do not find any similar issue being reported online either. Anybody knows how I can resolve this?

Here is the output of ng -v:

Your global Angular CLI version (8.2.0) is greater than your local
version (7.3.9). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".

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


Angular CLI: 7.3.9
Node: 10.16.0
OS: darwin x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.9
@angular-devkit/build-angular     0.8.9
@angular-devkit/build-optimizer   0.8.9
@angular-devkit/build-webpack     0.8.9
@angular-devkit/core              0.8.9
@angular-devkit/schematics        7.3.9
@angular/cdk                      7.3.7
@angular/cli                      7.3.9
@ngtools/webpack                  6.2.9
@schematics/angular               7.3.9
@schematics/update                0.13.9
rxjs                              6.2.2
typescript                        3.2.4
webpack                           4.16.4

Also here is my tsconfig.json:

{
    "compileOnSave": false,
    "compilerOptions": {
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "importHelpers": true,
        "target": "es5",
        "module": "es2015",
        "typeRoots": ["node_modules/@types"],
        "lib": ["es2017", "dom"],
        "skipLibCheck": true,
        "skipDefaultLibCheck": true,
        "baseUrl": ".",
        "paths": {
            "@app/api-interface": ["libs/api-interface/src/index.ts"],
            "@app/shared-lib": ["libs/shared-lib/src/index.ts"]
        }
    },
    "exclude": ["node_modules", "tmp"]
}
like image 302
Nylon Smile Avatar asked Aug 02 '19 02:08

Nylon Smile


1 Answers

The issue has been reported by other users as well. You can see the below github thread

https://github.com/ngx-rocket/generator-ngx-rocket/issues/472#issuecomment-512598966

There is workaround though. You can change the AppModule import in your main.ts from

import {AppModule} from './app'; 

to

import {AppModule} from './app/app.module';
like image 147
Tarun Lalwani Avatar answered Nov 13 '22 00:11

Tarun Lalwani