Nativescript ::错误TS2307:找不到模块'image-asset'

Posted

技术标签:

【中文标题】Nativescript ::错误TS2307:找不到模块\'image-asset\'【英文标题】:Nativescript : : error TS2307: Cannot find module 'image-asset'Nativescript ::错误TS2307:找不到模块'image-asset' 【发布时间】:2017-03-14 11:33:17 【问题描述】:

android API21 tns 2.3.0

我正在尝试使用nativescript-sdk-examples-ng 实现相机组件

实现代码后,我在运行应用程序时收到此错误 -

tns livesync ios --device 7a3c131309432ebae1a483f134ec8a4f8cdeecf4 --watch

您的应用程序将仅部署在由提供的索引或标识符指定的设备上。 从 /Users/mohit/work/Mobile/native/finly-ng/hooks/before-prepare/nativescript-dev-typescript.js 执行 before-prepare 钩子 找到对等 TypeScript 2.0.3 app/pages/expensephoto/expense-photo.component.ts(2,28): 错误 TS2307: 找不到模块 'image-asset'。

node_modules/nativescript-camera/nativescript-camera.d.ts(1,29):错误 TS2307:找不到模块 'image-asset'。

TypeScript 编译器失败,退出代码为 1

我该如何解决这个问题?

【问题讨论】:

嗨 moaglee,您能否提供有关您正在部署 nativescript-sdk-examples-ng 的设备的更多信息。我在 iOS 和 Android 设备上对其进行了测试,一切都按预期工作。同时,尝试删除 node_modules platformshooks 文件夹。使用npm cache clear 清理缓存并尝试再次构建它tns run <platform_name> 【参考方案1】:

您所指的示例应用程序正在使用 image-asset 模块所在的 tns-core-modules@next。该模块将与 NativeScript 2.4.0 一起正式发布,预计将在几天内发布。

同时,如果您想试验此功能和其他未发布的功能,您可以像这样安装@next of tns-core-modules。

tns plugin remove tns-core-modules
tns plugin add tns-core-modules@next

现在您的应用程序将可以访问 image-asset。

【讨论】:

以上是关于Nativescript ::错误TS2307:找不到模块'image-asset'的主要内容,如果未能解决你的问题,请参考以下文章

打字稿导入文本文件“错误 TS2307:找不到模块”

Angular 2:错误 TS2307:找不到模块“socket.io-client”

错误 TS2307:找不到模块“fs”或其相应的类型声明

错误TS2307:找不到模块(但在运行js时可以)

NRWL NX 导入库错误 TS2307:找不到模块“@eduboard/interfaces”

TS2307 构建:找不到模块“lodash”