angular - Angular Universal“找不到模块文件(/src/app/.ts)”
问题描述
我有一个最初在 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"]
}
解决方案
其他用户也报告了该问题。你可以看到下面的github线程
https://github.com/ngx-rocket/generator-ngx-rocket/issues/472#issuecomment-512598966
虽然有解决方法。您可以在from中更改AppModule
导入main.ts
import {AppModule} from './app';
至
import {AppModule} from './app/app.module';
推荐阅读
- tensorflow - ValueError: 层序贯_12 的输入 0 与层不兼容
- java - 无法编译 ToBooleanBiFunction.java
- python - 代表networkx文档中节点的字母“u”和“v”代表什么?
- python - 如何在python中计算欧几里得距离
- c# - 如何在多个 SQL Server 实例之间执行异步分布式事务
- python - Python虚拟环境组织与管理
- javascript - 如何在不使用任何 3rd 方库的情况下在 React 中创建搜索框功能
- pyqt - 使用 PyQt5 将按钮连接到不同选项卡上的功能
- javascript - Puppeteer-page.evaluate() 没有按预期工作
- php - 使用数组并将图像链接输出到代码?