Cannot find any tns-core-module/ui Modules NativeScript

心不动则不痛 提交于 2019-12-13 03:51:23

问题


I am writing a {N}-Application and need to import Images from the tns-core-modules/ui/image-module. Sadly he says that he cannot find that target in the tns-core-module.

My code:

import * as ImageModule from "tns-core-module/ui/image";

What am I supposed to do now? How can I fix this?

My npm --version: 3.10.10

My node -v: v6.11.1

My TS-Version: 2.4.2

The tns-core-modules are Version 2.2.1 in my package.json


回答1:


Are you sure that the path you provided is valid? It seems like you want to reference it relatively, but you might have to go up a few levels if you are. For instance:

import * as ImageModule from "../tns-core-module/ui/image"; //This will go up two levels.

Alternatively, you may be able to import the module using a path declared in your tsconfig.json file. Something along the lines of

        "paths": {
        "*": [
            "./node_modules/tns-core-modules/*"
        ]
    }

If that's the case, you can simply import by using

imprt * as ImageModule from "ui/images";


来源:https://stackoverflow.com/questions/45814066/cannot-find-any-tns-core-module-ui-modules-nativescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!