从Angular 5

时间:2018-01-31 04:53:01

标签: angular angular-cli node-modules onsen-ui

我正在尝试使用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"
        ],

我刚检查了CSS文件,它们确实存在于此文件夹中 CSS files in project

然后我看到了这个错误

错误在./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

Error in detail

1 个答案:

答案 0 :(得分:0)

我使用的是Angular CLI 1.6.6,我通过运行npm install -g @ angular / cli @ latest将其更新为1.6.7。这解决了问题