Error TS2749: 'Device' refers to a value, but is being used as a type here. Did you mean 'typeof Device'?

I am facing a problem with “Device” from @ionic-native/device :

When I run ng test I have an error message telling me:

error TS2749: 'Device' refers to a value, but is being used as a type here.
Did you mean 'typeof Device'? 

Searching on google, I found the problem usually lies on the missing /ngx at the end of the import.

My problem is different, because I have the /ngx at the end of the @import:

import { Device } from '@ionic-native/device/ngx';

I installed the plugin as the doc says it should be installed:

ionic cordova plugin add cordova-plugin-device
npm i @ionic-native/device

I have this error even after doing a rm -rf node_modules and npm i.

Here is my package.json:

{
  [...],
  "dependencies": {
    "@angular/animations": "^10.1.2",
    "@angular/cdk": "^10.2.3",
    "@angular/common": "^10.0.14",
    "@angular/core": "~10.1.2",
    "@angular/forms": "~10.0.0",
    "@angular/platform-browser": "^10.0.14",
    "@angular/platform-browser-dynamic": "~10.0.0",
    "@angular/router": "~10.0.0",
    "@capacitor/core": "2.4.1",
    "@ionic-native/barcode-scanner": "^5.28.0",
    "@ionic-native/camera": "^5.28.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/device": "^5.28.0",
    "@ionic-native/diagnostic": "^5.28.0",
    "@ionic-native/file": "^5.28.0",
    "@ionic-native/keyboard": "^5.28.0",
    "@ionic-native/network": "^5.28.0",
    "@ionic-native/splash-screen": "^5.28.0",
    "@ionic-native/sqlite": "^5.28.0",
    "@ionic-native/status-bar": "^5.28.0",
    "@ionic/angular": "^5.3.3",
    "@ng-idle/core": "^10.0.0-beta.1",
    "@ng-idle/keepalive": "10.0.0-beta.1",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "angular2-moment": "^1.9.0",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-sqlite-storage": "^5.1.0",
    "hammerjs": "^2.0.8",
    "linq-collections": "^1.0.254",
    "moment": "^2.28.0",
    "ng-pick-datetime": "^7.0.0",
    "ngx-simple-modal": "^1.4.13",
    "phonegap-plugin-barcodescanner": "^8.1.0",
    "rxjs": "^6.6.3",
    "rxjs-compat": "^6.6.3",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.0",
    "@angular/cli": "^10.1.2",
    "@angular/compiler": "~10.0.3",
    "@angular/compiler-cli": "~10.0.3",
    "@angular/language-service": "~10.0.0",
    "@capacitor/cli": "2.4.1",
    "@ionic/angular-toolkit": "^2.3.0",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "karma-junit-reporter": "^2.0.1",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-file": {},
      "cordova-plugin-device": {}
    }
  }
}

What can I do?

I found the problem:

ONE of my files had a missing /ngx at the end of the import, and it produced errors in other files that had the /ngx as if they did not…

Conclusion: Check all the files when you have the same error in multiple files, and not just one of them.

1 Like

Thanks it really helped!