错误TS2307:找不到模块'bluebird' [英] error TS2307: Cannot find module 'bluebird'

查看:3824
本文介绍了错误TS2307:找不到模块'bluebird'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用 Ionic 2 Angular 2 打字稿版本开发应用。我决定使用库 amqp-ts 在我的应用中包含消息。我通过npm安装了这个库,如:

I am currently trying to develop an app using Ionic 2 and Angular 2 with Typescript version. I decided to use the library amqp-ts to include messaging in my app. I installed the library via npm like:

npm install amqp-ts

一切都很顺利,现在我有这样的事情:

Everything went fine and now I've got something like this:

/ app root directory
+ node_modules
    - amqp-ts
        - lib 
            -  amqp-ts.d.ts
        - node_modules
            -  amqplib
            -  bluebird
            -  winston

问题现在开始:我导入了库中的库是在文档的示例中完成的......

The problems begin now: I import the library into my component as it is done in the example of the documentation...

import * as Amqp from "amqp-ts";

...当我尝试部署应用程序时,我收到下一条错误消息:

... and when I try to deploy the app I get the next error messages:

TypeScript error: C:/APPs/Test/Ionic2Angular2App/node_modules/amqp-ts/lib/amqp-ts.d.ts(2,26): Error TS2307: Cannot find module 'bluebird'.
TypeScript error: C:/APPs/Test/Ionic2Angular2App/node_modules/amqp-ts/lib/amqp-ts.d.ts(50,12): Error TS2304: Cannot find name 'Buffer'.

1。与第一条错误消息相关的行

// exported Typescript type definition for AmqpSimple
import * as Promise from "bluebird";
[...]

2。与第二条错误消息相关的行(相同文件:amqp-ts.d.ts)

export class Message {
    content: Buffer;
    [...]
}

我希望你能帮助我,请。

I hope you can help me, please.

推荐答案

除常规软件包安装外,还需要安装TypeScript类型。类型与头文件类似,它们包含所有方法/类/接口定义。

Additionally to regular package install you need to install TypeScript typings. Typings are like header files, they contain all methods/classes/interfaces definitions.

要安装打字,您需要一个打字工具。最好的方法是全局安装它,这样你就可以在每个项目中使用它

To install typings you need a typings tool. The best way is to install it globally so you can use it in every project

npm install typings --global

然后在项目中安装新的打字很简单,首先搜索库:

Then installing new typings inside your project is pretty simple, first search for library:

typings search bluebird

安装它:

typings install --save bluebird

更多信息: https://github.com/typings/typings

这篇关于错误TS2307:找不到模块'bluebird'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆