cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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%8bns...

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?

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

690_haieroversea

Were you able to resolve your issue? If any of the below responses helped you, then please mark the helpful answer by accepting it OR post an answer so others might benefit from your findings.

Regards, Jitendra (SAP Community Moderator)

Accepted Solutions (1)

Accepted Solutions (1)

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

690_haieroversea

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

Answers (1)

Answers (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

690_haieroversea

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.

0 Kudos

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