我正在尝试使用OnsenUI 2创建模板,但我无法从.angular-cli.json文件中的node_modules文件夹加载CSS文件。我按照https://onsen.io/v2/guide/angular2/#angular-2
的说明做了这个"styles": [
"../node_modules/onsenui/css/onsenui.css",
"../node_modules/onsenui/css/onsen-css-components.css",
"styles.css"
],
然后我看到了这个错误
错误在./node_modules/css-loader?{"sourceMap":false,"import":false}!。/ node_modules / postcc-loader / lib?{“”“”:“posttcss”,“sourceMap”:假}!./ node_modules / onsenui / CSS / onsenui.css 模块构建失败:错误:无法解析'C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ onsenui \ css'中的'ionicons / css / ionicons.min.css' 在onError(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ Resolver.js:61:15) 在loggingCallbackWrapper(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19) at runAfter(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ Resolver.js:158:4) 在innerCallback(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ Resolver.js:146:3) 在loggingCallbackWrapper(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19) 在下一个(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ tapable \ lib \ Tapable.js:252:11) 在C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ UnsafeCachePlugin.js:40:4 在loggingCallbackWrapper(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19) at runAfter(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ Resolver.js:158:4) 在innerCallback(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ Resolver.js:146:3) 在loggingCallbackWrapper(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19) 在下一个(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ tapable \ lib \ Tapable.js:252:11) 在innerCallback(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ Resolver.js:144:11) 在loggingCallbackWrapper(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19) 在下一个(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ tapable \ lib \ Tapable.js:249:35) at resolver.doResolve.createInnerCallback(C:\ Users \ mauri \ Documents \ GitHub \ IMS_MobileApps \ Demos \ Demos - OnsenUI \ demo1 \ node_modules \ enhanced-resolve \ lib \ DescriptionFilePlugin.js:44:6) @ ./node_modules/onsenui/css/onsenui.css 4:14-119 @ multi ./node_modules/onsenui/css/onsenui.css ./node_modules/onsenui/css/onsen-css-components.css ./src/styles.css
答案 0 :(得分:0)
我使用的是Angular CLI 1.6.6,我通过运行npm install -g @ angular / cli @ latest将其更新为1.6.7。这解决了问题