Skip to Content

MDK issue : Cannot find module 'tns-core-modules'

I create an extension of MDK with Business Application Studio followed :

https://blogs.sap.com/2020/08/10/add-nativescript-ui-chart-as-external-plugin-to-mdk-exte%e2%80%8bnsion-app/

in the main-module.ts file , the code is issue:

import { Observable } from 'tns-core-modules/data/observable';

issue : Cannot find module 'tns-core-modules/data/observable'.ts(2307)

I have checked the tsconfig.json file ,it seems OK.

Also,I followed other documents like :

https://developers.sap.com/tutorials/cp-mobile-dev-kit-slider-extension.html

It also has this kind of issue -- the .ts file .

I don't know why,is there something I missed?

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Aug 25 at 06:51 AM

    Hong Wei Ma

    Are you talking about error showing up in .ts files in MDK editor (WebIDE/BAS) ?

    If so, you can ignore it. There is currently no reference of such libraries in the editor hence you see that "cannot find module..." errors. This is handled at runtime in MDK client. These errors should not stop you deploying your metadata project to Mobile Services.

    Add a comment
    10|10000 characters needed characters exceeded

    • Unfortunally,if l leave the error in .ts files,it will cause error when deploy the Application.app.

      ModuleNotFoundError:Modulenotfound: Error: Can't resolve './main-model' in '/tmp/vscode-unpacked/vscode_npm_@ext-mdkvsc-npm-rel_mdkvsc-wing@1.2.23/extension/tools/application-bundler/build.definitions/NS_CustomerSales/Extensions/SalesChartModule/controls',ModuleNotFoundError: Module not found: Error: Can't resolve 'nativescript-ui-chart'in'/tmp/vscode-unpacked/vscode_npm_@ext-mdkvsc-npm-rel_mdkvsc-wing@1.2.23/extension/tools/application-bundler/build.definitions/NS_CustomerSales/Extensions/SalesChartModule/controls'
      undefined
  • Posted on Aug 26 at 08:22 PM

    Hong Wei Ma

    You will need to make sure you update your externals reference in BAS to include nativescript-ui-chart so it can deploy to mobile services.

    1. Select File > Settings > Open Preferences
    2. Search for MDK and click the Edit in settings.json link under Bundler Externals to open settings.json in the editor.
    3. Set your mdk.bundlerExternals as shown below
    4. Save your changes
    5. Rerun the MDK: Deploy again
    { 
        "java.jdt.ls.vmargs": "-DwatchParentProcess=false -noverify -Xmx512m -XX:+UseG1GC -XX:+UseStringDeduplication", 
        "java.configuration.checkProjectSettingsExclusions": false, 
        "java.configuration.updateBuildConfiguration": "automatic", 
        "java.autobuild.enabled": false,
        "files.exclude": { 
            "**/.classpath": true,
            "**/.project": true,
            "**/.settings": true,
            "**/.factorypath": true,
            "**/.extension": true 
        },
        "ports.excludeExposeNotification": { 
            "ports": [ 8000, 8005, 8009 ],
            "ranges": [ { 
                "from": 0,
                "to": 0 
            } ] 
        },
        "spring-boot.ls.checkJVM": false,
        "workbench.iconTheme": "theia-file-icons",
        "workbench.list.openMode": "singleClick",
        "workspace.preserveWindow": false,
        "mdk.validateBeforeBundle": false,
        "mdk.bundlerExternals": [
            "nativescript-ui-chart"
        ],
        "mck.mobileservices": [] 
    }

    --Bill

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.