typescript - TS2307 : Cannot find module 'ionic/ionic'

标签 typescript angular tsc tsconfig ionic2

当尝试将 tsc 与我的 ionic2 项目一起使用时,我在 typescript 文件上收到以下错误。

错误: TS2307:找不到模块“ionic/ionic”


代码:

import {Page} from "ionic/ionic" //error happens on this line

@Page({
  templateUrl: 'app/list/list.html',
})
export class ListPage {
  constructor() {}
}

我的 tsconfig.json 文件:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "sourceMap": true,
    "isolatedModules": true,
    "noEmitOnError": false,
    "rootDir": ".",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  },
  "compileOnSave": false
}

我的 npm -g 列表:

cordova@5.4.0
ionic@2.0.0-alpha.23
npm@3.4.1
typescript@1.6.2

最佳答案

参见 issue 84

我们仍然需要为 ionic 2 创建一个定义文件。所以在那之前,typescript 编译器会大喊大叫,但它仍然会正确编译代码。

关于typescript - TS2307 : Cannot find module 'ionic/ionic' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33839269/

相关文章:

Angular 2 :How to detect the completion of HTTP request?

javascript - NestJs:如何使 Body 输入形状与实体的 DTO 不同?

angular - Material 表默认排序不起作用

具有两种方式绑定(bind)的 Angular 4 单元测试形式。从 View 更新模型时出现问题

javascript - 管道内的映射被忽略并且不会触发http调用

typescript - 如何从 typescript 组件访问 Vue 原型(prototype)属性

Typescript IDE 自动从 dist 导入而不是 src

TypeScript 节点示例无法编译

node.js - Volta 与yarn run 构建系统找不到指定的路径