我正在将 Angular 6 应用程序更新到 Angular 8。更新了几个软件包并修复了许多错误后,我终于遇到了这个错误
到目前为止我已尝试以下步骤:
- 卸载 webpack。
- 删除node_modules。
- 全局安装 webpack
- 运行
npm i
我收到以下错误:
ERROR in ./src/assets/scss/style.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/assets/scss/style.scss)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Failed to find '@swimlane/ngx-datatable/release/themes/material.css'
in [
c:\xampp\htdocs\hrflo\admin_frontend_updated\src\assets\scss
]
at resolveModule.catch.catch (c:\xampp\htdocs\hrflo\admin_frontend_updated\node_modules\postcss-import\lib\resolve-id.js:35:13)
我的“package.json”文件是:
{
"name": "hrflo-admin",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/build-angular": "^0.803.3",
"@angular/animations": "^8.2.5",
"@angular/cdk": "^8.1.1",
"@angular/common": "^8.2.5",
"@angular/compiler": "^8.2.5",
"@angular/core": "^8.2.5",
"@angular/forms": "^8.2.5",
"@angular/http": "^7.2.15",
"@angular/platform-browser": "^8.2.5",
"@angular/platform-browser-dynamic": "^8.2.5",
"@angular/router": "^8.2.5",
"@ng-bootstrap/ng-bootstrap": "^5.1.1",
"@ng-select/ng-select": "^3.0.7",
"@swimlane/ngx-datatable": "^16.0.2",
"angular-calendar": "0.27.18",
"angular-datatables": "^8.0.0",
"bootstrap": "^4.3.1",
"chart.js": "^2.7.2",
"chartist": "0.11.3",
"core-js": "^2.5.0",
"datatables.net": "^1.10.19",
"datatables.net-buttons": "^1.5.3",
"datatables.net-buttons-dt": "^1.5.3",
"datatables.net-colreorder": "^1.5.1",
"datatables.net-colreorder-dt": "^1.5.1",
"datatables.net-dt": "^1.10.19",
"datatables.net-editor": "^1.6.5",
"datatables.net-responsive": "^2.2.3",
"datatables.net-responsive-dt": "^2.2.3",
"datatables.net-select": "^1.3.0",
"datatables.net-select-dt": "^1.3.0",
"date-fns": "^2.0.1",
"daterangepicker": "^3.0.3",
"jquery": "^3.4.1",
"jquery-slimscroll": "1.3.8",
"jszip": "^3.1.5",
"moment": "^2.22.2",
"ng-chartist": "4.1.0",
"ng2-charts": "2.3.0",
"ng2-dragula": "2.1.1",
"ng2-file-upload": "1.3.0",
"ng2-smart-table": "1.5.0",
"ng4-intl-phone": "^1.2.1",
"ngx-bootstrap": "^5.1.1",
"ngx-perfect-scrollbar": "^8.0.0",
"ngx-quill": "7.3.0",
"ngx-scrollbar": "^5.0.2",
"ngx-select-ex": "^3.5.9",
"ngx-toastr": "10.2.0",
"pace-js": "1.0.2",
"popper.js": "^1.14.7",
"print-js": "^1.0.61",
"quill": "^1.3.6",
"rxjs": "^6.5.3",
"rxjs-compat": "^6.0.0-rc.0",
"zone.js": "^0.9.1"
},
"devDependencies": {
"@angular/cli": "^8.3.3",
"@angular/compiler-cli": "^8.2.5",
"@angular/language-service": "^8.2.5",
"@types/datatables.net": "^1.10.13",
"@types/datatables.net-buttons": "^1.4.0",
"@types/datatables.net-select": "^1.2.4",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.22",
"@types/node": "~12.7.4",
"codelyzer": "~5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"node-sass": "^4.12.0",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.19.0",
"typescript": "3.4.5"
}
}
我的“angular.json”文件是:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"hrflo-admin": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/hrflo-admin",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"./node_modules/angular-calendar/css/angular-calendar.css",
"./node_modules/quill/dist/quill.snow.css",
"./node_modules/dragula/dist/dragula.css",
"./src/assets/scss/style.scss",
"./node_modules/datatables.net-dt/css/jquery.dataTables.min.css",
"./node_modules/datatables.net-buttons-dt/css/buttons.dataTables.css",
"./node_modules/datatables.net-select-dt/css/select.dataTables.min.css",
"./node_modules/datatables.net-colreorder-dt/css/colReorder.dataTables.css",
"./node_modules/datatables.net-responsive-dt/css/responsive.dataTables.min.css",
"src/assets/dist/css/editor.dataTables.min.css",
"src/assets/dist/css/editor.bootstrap.min.css",
"./node_modules/daterangepicker/daterangepicker.css",
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"src/assets/dist/css/chosen.css",
"src/assets/scss/print-js/print.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/pace-js/pace.min.js",
"src/assets/js/jquery.sparkline.min.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/jszip/dist/jszip.js",
"node_modules/datatables.net-buttons/js/dataTables.buttons.js",
"node_modules/datatables.net-colreorder/js/dataTables.colReorder.js",
"node_modules/datatables.net-responsive/js/dataTables.responsive.js",
"node_modules/datatables.net-select/js/dataTables.select.min.js",
"node_modules/datatables.net-buttons/js/buttons.colVis.js",
"node_modules/datatables.net-buttons/js/buttons.flash.js",
"node_modules/datatables.net-buttons/js/buttons.html5.js",
"node_modules/datatables.net-buttons/js/buttons.print.js",
"src/assets/dist/js/dataTables.editor.min.js",
"src/assets/dist/js/chosen.jquery.js",
"src/assets/dist/js/editor.chosen.js",
"src/assets/dist/js/editor.ckeditor.js",
"src/assets/dist/js/editor.Mchosen.js",
"src/assets/dist/js/rangedate.js",
"src/assets/dist/js/scan.js",
"node_modules/moment/min/moment.min.js",
"node_modules/daterangepicker/daterangepicker.js",
"src/assets/js/wizard/jquery.steps.js",
"src/assets/js/wizard/main.js",
"src/assets/js/wizard/theme-map.js",
"src/assets/js/print-js/print.min.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "hrflo-admin:build"
},
"configurations": {
"production": {
"browserTarget": "hrflo-admin:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "hrflo-admin:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"hrflo-admin-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "hrflo-admin:serve"
},
"configurations": {
"production": {
"devServerTarget": "hrflo-admin:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "hrflo-admin"
}
最佳答案
从版本 16.0.0 开始,url 中不再有/release/-folder
https://github.com/swimlane/ngx-datatable/issues/1743#issuecomment-528952503
所以,您应该更改导入网址:“@swimlane/ngx-datatable/themes/material.css”
关于angular - 将 Angular 6 应用程序升级到 Angular 8 时加载 scss 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57832895/