15

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"]
}
7
  • Have you try to upgrade to angular v8 ? It seems you using CLI v8 but Angular v7 Commented Aug 9, 2019 at 14:48
  • 1
    Do you have a repo which one can try this on? Commented Aug 12, 2019 at 15:58
  • Does anything happen if you change your baseUrl to "./"? Commented Aug 12, 2019 at 17:33
  • @Mickers made no difference Commented Aug 12, 2019 at 18:13
  • @TarunLalwani , not sure how I can do it, the project is huge. But I can provide any file/configs that you think might be relevant. Commented Aug 12, 2019 at 18:14

2 Answers 2

18
+500

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';
Sign up to request clarification or add additional context in comments.

1 Comment

In my case I had to change @app/app.module to ./app/app.module. Just for others to notice :)
0

It looks very strange as the module file shows in the error is completely unrelevant, can you try adding the following to my tsconfig.json file

"moduleResolution": "node",

1 Comment

above line is already in tsconfig.json. I have updated the question with the full content of tsconfig.json, also a note about @nrwl/nx

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.