Search code examples
nativescriptnativescript-angular

Nativescript 6.1 returns an error when adding custom css file to the page


I've just updated my app to Nativescript 6.1 but I'm having this error calling page.addCss:

page.addCssFile('~/themes/' + settings.cssThemeName + '.css');

and I'm not getting this error:

Error: Could not load CSS from ~/themes/white.css: Error: require's first parameter should be string

Could it be a bug? I've tried multiple way to reach the file but I'm always getting the same error


Solution

  • I had the same issue after I upgraded some of the packages.

    upgrade all components to the latest version and everything it should be fine.

    This is what I currently have and it's working perfectly.

    √ Component nativescript has 6.1.0 version and is up to date.

    √ Component tns-core-modules has 6.1.0 version and is up to date.

    √ Component tns-android has 6.1.0 version and is up to date.

    "nativescript-dev-webpack": "^1.2.0",

    Don't forget to regenerate the webpack configuration and dependencies with

    npm i nativescript-dev-webpack@latest --save-dev ./node_modules/.bin/update-ns-webpack --deps --configs

    For more details here is the documentation Nativescript Upgrade Instructions