icanos / ng2-mqtt

Angular2 port of the mqttws31 library
17 stars 24 forks source link

index.ts is missing from the TypeScript compilation #22

Open rosariosanto opened 5 years ago

rosariosanto commented 5 years ago

I followed the steps to use ng2-mqtt described in the main page of this repo. But it seems that there is something extra that I need to do to get this running. I get the error bellow. If anyone looking at this post has a working example using ng2-mqtt and can share it, will be great. I attached the source code of my application, lawnClient.zip. If you have issue unzipping file, rename extension to "rar".

ERROR in ./node_modules/ng2-mqtt/index.ts Module build failed: Error: C:\devel\lawnClient\node_modules\ng2-mqtt\index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv). at AngularCompilerPlugin.getCompiledFile (C:\devel\lawnClient\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:740:23) at plugin.done.then (C:\devel\lawnClient\node_modules\@ngtools\webpack\src\loader.js:41:31) at at process._tickCallback (internal/process/next_tick.js:188:7)

lawnClient.zip

rosariosanto commented 5 years ago

Adding the index.js file into include in the tsconfig resulted in a different error: ERROR in No NgModule metadata found for 'AppModule'.

ggoodfrd commented 5 years ago

I found that changing the import to this fixed it:

import { Paho } from 'ng2-mqtt/mqttws31'; ✅

No need to edit the tsconfig file even though the error leads you in that direction. The import statement just doesn't point to the actual type definition when using this code:

import { Paho } from 'ng2-mqtt'; ❌

I see that @Anky001 has already submitted a Pull Request for this change: 😃 https://github.com/icanos/ng2-mqtt/pull/24/commits/a97bd63326c0c0657d04149bafa3aef80e6e5097

roniTheOtterCoders commented 5 years ago

facing same issue !! even changed import!