gpt4 book ai didi

javascript - 错误 : The loader in . css 未在 Angular 12.1.1 中返回字符串

转载 作者:行者123 更新时间:2023-12-05 00:27:13 25 4
gpt4 key购买 nike

我创建了一个新项目,但是每当我编译时都会收到以下 2 条错误消息:

Error: Module not found: Error: Can't resolve 'C:/Users/Avishek/Documents/practice/frontend/src/app/pages/admin/authentication/authentication.component.css' in 'C:\Users\Avishek\Documents\practice\frontend'



Error: The loader "C:/Users/Avishek/Documents/practice/frontend/src/app/pages/admin/authentication/authentication.component.css" didn't return a string.


甚至在几天前,我从未遇到过此类问题,我创建了一个具有相同 Angular 版本的项目仍然没有得到。以下是我的 tsconfig.json & package.json文件分别。
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": false,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2017",
"module": "es2020",
"lib": [
"es2018",
"dom"
],
"paths": {
"@directive/*": ["src/app/core/directives/*"],
"@guard/*": ["src/app/core/guards/*"],
"@interceptor/*": ["src/app/core/interceptors/*"],
"@pipe/*": ["src/app/core/pipes/*"],
"@service/*": ["src/app/core/services/*"],
"@custom-validator/*": ["src/app/core/validators/*"],
"@model/*": ["src/app/core/models/*"],
"@store/*": ["src/app/core/store/*"],
"@feature/*": ["src/app/features/*"],
"@page/*": ["src/app/pages/*"],
"@shared/*": ["src/app/shared/*"]
}
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true,
"strictPropertyInitialization": false
}
}
包.json
{
"name": "project",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.1.1",
"@angular/cdk": "^12.2.4",
"@angular/common": "~12.1.1",
"@angular/compiler": "~12.1.1",
"@angular/core": "~12.1.1",
"@angular/forms": "~12.1.1",
"@angular/material": "^12.2.4",
"@angular/platform-browser": "~12.1.1",
"@angular/platform-browser-dynamic": "~12.1.1",
"@angular/router": "~12.1.1",
"@kolkov/angular-editor": "^1.2.0",
"@ngxs/store": "^3.7.2",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.1.1",
"@angular/cli": "~12.1.1",
"@angular/compiler-cli": "~12.1.1",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"typescript": "~4.3.2"
}
}
请帮忙看看这是什么类型的问题,我该如何解决。

最佳答案

我的问题是我的项目被配置为使用 scss文件,但我从使用 css 的示例中复制了一些代码文件。所以在我的一个组件中,我有:

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
css stypeUrls 属性中的文件是错误的原因。

关于javascript - 错误 : The loader in . css 未在 Angular 12.1.1 中返回字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69148615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com