angular - TypeScript 编译中缺少 Angular- 模块。请通过 'files' 或 'include' 属性确保它在您的 tsconfig 中
问题描述
ng serve 后出现此错误: ./src/app/Modeles/utilisateurs.model.ts 中的错误模块构建失败(来自 ./node_modules/@ngtools/webpack/src/index.js):错误:C:\Users TypeScript 编译中缺少 \xx\src\app\Modeles\utilisateurs.model.ts。请通过 'files' 或 'include' 属性确保它在您的 tsconfig 中。
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"lib": [
"es2018",
"dom"
],
"types": ["gapi", "gapi.auth2"],
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
},
"include": [
"./src",
"node_modules/@jaspero/ng2-select",
"**/app/lazyModules/**/*.ts"
]
}
tsconfig.app.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["gapi", "gapi.auth2"],
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}
角.json:
"projects": {
"xx": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/xx",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"preserveSymlinks": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
},
解决方案
在 tsconfig.app.json 更改您的包含数组
"include": [
"src/**/*.d.ts"
]
至
"include": [
"src/**/*.d.ts",
"src/**/*.ts"
]
推荐阅读
- postgresql - 我需要将两列 (A1 * B1) 和 B2 处的答案相乘,然后将 A2 值 * B2 值相乘
- javascript - 在 Mozilla Firefox 中使用 showModal() 方法
- ios - react-naitve xcode build main.jsbundle no such file error after watchman lost connected log
- python - 如何使用 pygame(如 T-rex 游戏)创建多个横向移动的精灵对象
- sql-server - 在多值字符串中搜索的最佳方法
- c# - 启动文本随机化它,它不会让我发布因为名称
- sql - 错误:使用计数和查找百分比时在“从”处或附近出现语法错误
- r - 如何基于 R 中的多列展开单列?
- apache-kafka - 消费端的并行处理和维护秩序 - Kafka + Camel
- node.js - 使用 CloudFront 和 FFMPEG 通过 HTTP 进行实时流式传输存在延迟问题