0

I'm trying to install this npm package. As it's said in the instructions, I should do

npm install angular2-websocket

which gives me this:

angular-quickstart@1.0.0 /home/me/dir
├─┬ angular2-websocket@0.9.0 
│ └── bluebird@3.4.7 
├── UNMET PEER DEPENDENCY reflect-metadata@^0.1.8
├── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12
├── UNMET PEER DEPENDENCY typescript@2.0.10
└── UNMET PEER DEPENDENCY zone.js@0.7.6

As I've researched, these peer dependencies are dependencies that must be manually installed, but there's no mention about them in the README. I left as it is.

Then comes the usage section, before the compile section, so I don't know what I should do. But I compiled anyways, and I got no errors. I just did as it says in the README:

npm run typings
npm run compile

When I try, however, to compile a test file that just imports the angular2-websocket library, I get:

node_modules/angular2-websocket/angular2-websocket.d.ts(36,30): error TS2304: Cannot find name 'Promise'.
../../node_modules/rxjs/Observable.d.ts(69,60): error TS2304: Cannot find name 'Promise'.
../../node_modules/rxjs/Observable.d.ts(69,70): error TS2304: Cannot find name 'Promise'.

If Promises are available even in browsers, then why the name isn't found? Also, why the packages to this library are listed as peer?

  • [possible duplicate](http://stackoverflow.com/questions/39116687/error-ts2304-cannot-find-name-promise). It may be that your `typescript.json` file has a target of `es5` when it needs to be `es6`. Promise syntax wasn't part of `ES5`, so that would trigger the error. – the holla Feb 09 '17 at 11:08
  • @DianaHolland but it needs to run on browsers, it's angular –  Feb 10 '17 at 04:56
  • I don't know much about Angular, but I do work in Node and to me it seems like this is your issue: the npm package you installed uses Promise syntax, but your project isn't set up in ES6. you can use ES6 and then use something like [Babel](https://babeljs.io/) to transpile your ES6 code down to ES5 for browsers. Here's [an example](https://medium.com/angular-2-with-es6/angular-2-with-es6-the-5-minute-quickstart-a9e4eb0bffcc#.dei74jt93) of an Angular 2 ES6 project setup. Another option would be to use a different package that doesn't require promise syntax. – the holla Feb 10 '17 at 17:54

0 Answers0