1

I put in tns imports to implement functionality in my nativescript app on a mobile Android emulator. When compiling with the ng command however, the tns core modules fail to resolve and the compiler throws an error.

The error message:

ERROR in ./src/app/players/players-login/players-login.component.ts
Module not found: Error: Can't resolve 'tns-core-modules/application-settings' in 'C:\Users\Ace\eclipse-workspace\arenamaster\src\app\players\players-login'
ERROR in ./src/app/players/players-login/players-login.service.ts
Module not found: Error: Can't resolve 'tns-core-modules/application-settings' in 'C:\Users\Ace\eclipse-workspace\arenamaster\src\app\players\players-login'
ERROR in ./src/app/players/players-login/players-login.component.ts
Module not found: Error: Can't resolve 'tns-core-modules/platform' in 'C:\Users\Ace\eclipse-workspace\arenamaster\src\app\players\players-login'
ERROR in ./src/app/players/players-login/players-login.service.ts
Module not found: Error: Can't resolve 'tns-core-modules/platform' in 'C:\Users\Ace\eclipse-workspace\arenamaster\src\app\players\players-login'

The import lines:

import { isAndroid, isIOS, device, screen } from 'tns-core-modules/platform';
import * as appSettings from 'tns-core-modules/application-settings';

tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
Tony Ngo
  • 19,166
  • 4
  • 38
  • 60
Ace Zhang
  • 81
  • 1
  • 8
  • module available in `node_modules`? – Nithin Kumar Biliya Sep 24 '19 at 02:56
  • yes, I ran `npm install tns-core-modules` twice. Both times console output told me it was already installed. – Ace Zhang Sep 24 '19 at 03:40
  • could be a version miss match issue. Check [this](https://github.com/NativeScript/nativescript-schematics/issues/37), [this](https://github.com/NativeScript/nativescript-schematics/issues/154) and [this](https://stackoverflow.com/a/52919046/1298824) – Nithin Kumar Biliya Sep 24 '19 at 05:46

0 Answers0