Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13526

Error: "Cannot find name 'device'." in a Angular 4 Project while running ng build.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Invalid
    • None
    • None
    • cordova-plugin-device
    • None
    • cordova-plugin-file: 4.3.3
      cordova: 7.0.1
      Desktop: Windows 10

    Description

      I would like to load an Angular 4 project with Cordova. For this, I build my Amngular App with ng build and copy it into the /WWW directory of Cordova. This works so far.

      Now I have installed the file plugin in the cordova project. In addition, I have installed the NPM module @types/cordova-plugin-file to the angular project, where the type definitions are inclued.

      the structure:

      • cordova projekt-root
          • node_modules
          • www
          • plugins
                • cordova-file-plugin
          • ......
          • angular projekt-root
                • node_modules
                      • @types
                            • cordova-file-plugin
                • src
                • tsconfig.json
                • .....

      Here are the typesRoots Part of my tsconfig.json file, wich include all index.d.ts files from the"node_modules/@types" folder.

      "typeRoots": [
      "node_modules/@types"
      ]

      It works for example for jJQuery or other libraries. But not for all cordova plugins. Because, in the index.d.ts files from cordova plugins, there are no exports. There are ony declarations from variables. But not exported.

      When i run ng build, i get the error "Cannot find name 'device'." Is there an error in the typedefinitions from the cordova plugins?

      Attachments

        Activity

          People

            Unassigned Unassigned
            roy_lec Roy Ackermann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: