我已经将Angular5更新为Angular6。直到现在,我一直在使用webpack-dev-server启动该应用程序。我想让ng服务该应用程序。
但是,当我运行ng服务时,出现以下错误:-
模块构建失败:TypeError:无法读取未定义的属性'sassLoader'
在getLoaderConfig(C:\ Work \ Dev \ Accesslint-Checkins \ Accesslint-UI \ node_modules \ sass-loader \ index.js:389:39)
在Object.module.exports(C:\ Work \ Dev \ Accesslint-Checkins \ Accesslint-UI \ node_modules \ sass-loader \ index.js:42:23)
./src/assets/sass/app.scss中的错误(./node_modules/raw-loader!./node_modules/postcss-loader/lib ??嵌入!./ node_modules / sass-loader ?? ref--15-3 !./ src / assets / sass / app.scss)
以下是angular.json,并且某种程度上没有angular-cli.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"Accesslint-ui": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/Accesslint-ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"node_modules/bootstrap/scss/bootstrap.scss",
"src/styles.scss",
"src/assets/sass/app.scss"
],
"scripts": []
},
"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": "Accesslint-ui:build"
},
"configurations": {
"production": {
"browserTarget": "Accesslint-ui:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "Accesslint-ui: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/**"
]
}
}
}
},
"Accesslint-ui-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "Accesslint-ui:serve"
},
"configurations": {
"production": {
"devServerTarget": "Accesslint-ui:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "Accesslint-ui"
}
最佳答案
另外,请检查您在应用程序中使用的node-sass和sass-loader版本。尝试使用最新版本将解决此问题。
这是我的应用程序中使用的版本
node-sass : 4.9.3
sass-loader: 7.1.0
关于css - 模块构建失败:TypeError:无法读取未定义的属性'sassLoader',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52037761/