AntonioMendez AntonioMendez - 7 months ago 321
Node.js Question

error TS2307: Cannot find module 'bluebird'

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. The line related to the first error message

// 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)

export class Message {
content: Buffer;

I hope you can help me, please.


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

Install it :

typings install --save bluebird

More info :