Angular Universal“找不到模块文件(/src/app/.ts)”

时间:2019-08-02 02:29:00

标签: angular angular-universal

我有一个最初是在Angular 2上开发的应用程序,随着使用Angular发行文档发布新版本的Angular,我已逐渐迁移。目前,应用程序中的angular版本为:7.2.15

我还应该补充一点,我已经使用@ nrwl / nx将NestJs + Angular项目移动到了一个单声道仓库中,但是即使没有@ nrwl / nx的单声道仓库,即使试图将通用性添加到我以前的版本中,它也提供了相同的功能错误

现在,当我尝试添加角度通用支架时:

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

我遇到以下错误:

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

这是我遇到的唯一错误,因此很难知道从哪里开始。我也找不到在线报告任何类似的问题。有人知道我该如何解决?

这是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

这也是我的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"]
}

2 个答案:

答案 0 :(得分:2)

该问题也已被其他用户报告。您可以看到以下github线程

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

但是有解决方法。您可以从{p>更改AppModule中的main.ts导入

import {AppModule} from './app'; 

import {AppModule} from './app/app.module';

答案 1 :(得分:0)

看起来很奇怪,因为模块文件显示的错误是完全不相关的,您可以尝试将以下内容添加到我的tsconfig.json文件中

"moduleResolution": "node",
相关问题