我密切平行關係how-to-use-moment-js-library-in-angular-2-typescript-app採取的辦法,但仍然得到error TS2307: Cannot find module 'mqtt'.
如何在角2打字稿應用程序中使用(mqtt)js庫?
npm install --save mqtt
<s>typings install --save mqtt</s
未找到分型但這並...
typings install mqtt --save --ambient
我tsconfig.conf看起來像這樣
{
"compilerOptions": {
"noImplicitAny": true,
"module": "commonjs",
"target": "ES5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true
},
"files": [
"ng2-mqtt.ts"
],
"exclude": [
"node_modules"
]
}
and ng2-mqtt.ts
只是有這個...
export * from './src/mqtt.service'
和./src/mqtt.service.ts
具有..
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],分型0.8.1,NPM 20年2月14日,節點v4.4.1, Windows 7
是不是會使用Angular 2與其類型腳本之外的元素太難了?