[英]error TS2307: Cannot find module 'bluebird'
我目前正在嘗試使用Ionic 2和Angular 2和Typescript 版本開發一個應用程序。 我決定使用庫amqp-ts在我的應用程序中包含消息傳遞。 我通過 npm 安裝了庫,例如:
npm install amqp-ts
一切順利,現在我得到了這樣的東西:
/ app root directory
+ node_modules
- amqp-ts
- lib
- amqp-ts.d.ts
- node_modules
- amqplib
- bluebird
- winston
問題現在開始了:我將庫導入到我的組件中,就像在文檔示例中所做的那樣……
import * as Amqp from "amqp-ts";
...當我嘗試部署應用程序時,我收到了下一條錯誤消息:
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;
[...]
}
我希望你能幫助我,拜托。
除常規軟件包安裝外,您還需要安裝TypeScript類型。 類型與頭文件類似,它們包含所有方法/類/接口定義。
要安裝打字,你需要一個打字工具。 最好的方法是全局安裝它,以便在每個項目中使用它
npm install typings --global
然后在項目中安裝新的打字很簡單,首先搜索庫:
typings search bluebird
安裝它:
typings install --save bluebird
更多信息: https : //github.com/typings/typings
我也遇到了同樣的問題,但對我來說上面的答案是行不通的。 簡單地運行時:
npm i bluebird
解決問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.