[英]error TS2307: Cannot find module 'bluebird'
I am currently trying to develop an app using Ionic 2 and Angular 2 with Typescript version .我目前正在尝试使用Ionic 2和Angular 2和Typescript 版本开发一个应用程序。 I decided to use the library amqp-ts to include messaging in my app.
我决定使用库amqp-ts在我的应用程序中包含消息传递。 I installed the library via npm like:
我通过 npm 安装了库,例如:
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. The line related to the first error message 1.与第一条错误消息相关的行
// exported Typescript type definition for AmqpSimple
import * as Promise from "bluebird";
[...]
2. The line related to the second error message (same file: amqp-ts.d.ts) 2.与第二个错误消息相关的行(同一个文件:amqp-ts.d.ts)
export class Message {
content: Buffer;
[...]
}
I hope you can help me, please.我希望你能帮助我,拜托。
Additionally to regular package install you need to install TypeScript typings. 除常规软件包安装外,您还需要安装TypeScript类型。 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
Install it : 安装它:
typings install --save bluebird
More info : https://github.com/typings/typings 更多信息: https : //github.com/typings/typings
I too faced same issue, but for me above answer is not working.我也遇到了同样的问题,但对我来说上面的答案是行不通的。 While simply running:
简单地运行时:
npm i bluebird
resolving the issue解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.