Angular2 / Typescript:无法解析TNS导入

时间:2019-09-24 01:19:29

标签: angular typescript nativescript

我放入tns导入以在移动Android模拟器上的nativescript应用中实现功能。但是,使用ng命令进行编译时,tns核心模块无法解析,并且编译器将引发错误。

错误消息:

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'

导入行:

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"
    ]
  }
}

0 个答案:

没有答案