New project - cordova-plugin-device - error 'device' is not defined

  • Hello,
    I created a new quasar project, added cordova and played around a little bit.

    Everything is working, I can deploy the app on my phone and run it in the emulator.

    Right now, I need to get some device information and I wanted to use cordova-plugin-device for that. The plugin is loading, like every plugin I installed. I can see it in the developer window (safari).

    Now, I try to get the device information, like it is described in the documentation:

    Something like that in the App.vue:

    mounted: function () {
        document.addEventListener('deviceready', this.onDeviceReady, false)
      methods: {
        onDeviceReady: function () {
          console.log('cordova', cordova)
          console.log('device', device)

    But the following error always appears in the console:

    error ‘device’ is not defined no-undef

    How can I solve that? I removed the platform already and re-added it.

    I am out of ideas and cannot find anything related on the internet.

    Thanks in advance

  • @Basti I think cordova.plugins.device is the way (for this plugin), i use it in my project, will check later coz im on mobile atm.

  • @metalsadman Thanks for the fast reply! cordova.plugins is undefined.
    When I look into the cordova_plugins.js

    cordova.define('cordova/plugin_list', function(require, exports, module) {
      module.exports = [
          "id": "cordova-plugin-device.device",
          "file": "plugins/cordova-plugin-device/www/device.js",
          "pluginId": "cordova-plugin-device",
          "clobbers": [
          "id": "cordova-plugin-splashscreen.SplashScreen",
          "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js",
          "pluginId": "cordova-plugin-splashscreen",
          "clobbers": [

    The “clobbers” are just directly device or navigator.splashscreen.

    I can access navigator.splashscreen but not device.

  • @Basti Hmm look like it’s should be ice then. Edit. Confirmed i am using window.device.

  • @metalsadman Thank you SO much! window.device has been the solution! I still don’t really get why, because I can access the rest of the plugins directly but its working like charm!

    You the best!

    Edit: I was already looking into the window object but could not find the device prop, so I was not even trying window.device. Magic happens.

  • @Basti not all cordova plugins are accessible the same way, some can be on cordova.plugins, navigator, window etc…

  • @metalsadman Hi friend. I’m to trying use the cordova file plugin but on Android I can’t access to cordova.file is undefined. I was put window, navigator, cordova, this.$q.cordova and doesn’t work. I dont know what to do already. Can you help me?

Log in to reply