I followed a similar approach as demonstrated in how-to-use-moment-js-library-in-angular-2-typescript-app but encountered the error message
error TS2307: Cannot find module 'mqtt'.
npm install --save mqtt
<s>typings install --save mqtt</s>
The above code did not find the typings, but this alternative method worked...
typings install mqtt --save --ambient
This is how my tsconfig.conf is configured:
{
"compilerOptions": {
"noImplicitAny": true,
"module": "commonjs",
"target": "ES5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true
},
"files": [
"ng2-mqtt.ts"
],
"exclude": [
"node_modules"
]
}
The content of ng2-mqtt.ts
is simply...
export * from './src/mqtt.service'
And ./src/mqtt.service.ts
includes...
import {Injectable} from 'angular2/core';
import * as mqtt from 'mqtt';
@Injectable()
export class MqttService {
constructor() {
//mqtt.connect('ws://10.0.1.100:3333')
// ...
}
}
tsc -version 1.8.10, [email protected], typings 0.8.1, npm 2.14.20, node v4.4.1, Windows 7
Is it going to be challenging to integrate Angular 2 with external elements beyond its TypeScript ecosystem?