triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Module not found #1

Closed aderbas closed 8 years ago

aderbas commented 8 years ago

I was looking for exactly this module, I tried to use but is not working.

$ tns create sample
$ cd sample/
$ npm install nativescript-socketio

In my main-page.ts:

import SocketIO = require('nativescript-socketio');

"Cannont find module 'nativescript-socketio' "

aderbas commented 8 years ago

Once installed I checked the directory and does not implement itself. captura de tela de 2016-04-14 15 19 49

triniwiz commented 8 years ago

npm install nativescript-socketio works fine for me try reinstalling the plugin also the Cannot find module 'nativescript-socketio' sometimes you can ignore that because i've seen it before if the emulator doesn't crash saying it cannot locate the module you can try logging the module instance console.log(SocketIO) or console.dump(SocketIO) you should see something like this

JS: function SocketIO(url, args, instance) {
JS:     if (app.android) {
JS:         if (instance) {
JS:             this.socket = instance;
JS:             return;
JS:         }
JS:         let opts = new IO.Options();
JS:         Object.assign(opts, args);
JS:         this.socket = IO.socket(url, opts);
JS:         this.socket.connect();
JS: 
JS:     }
JS: }
aderbas commented 8 years ago

I tried "npm install" and "tns plugin add" both commands install 'nativescript-socketio' on 'node-modules' but the folder structure are as the picture. I tried to run anyway

$ tns platform add android 
-> OK
$ tns prepare android
-> app/main-page.ts(5,27): error TS2307: Cannot find module 'nativescript-socketio'.
$ tns run android 
-> app/main-page.ts(5,27): error TS2307: Cannot find module 'nativescript-socketio'.
triniwiz commented 8 years ago

Thats odd try tns plugin add https://github.com/triniwiz/nativescript-socketio

aderbas commented 8 years ago

Okay, now downloaded correctly.

// OK
var SocketIO = require('nativescript-socketio'); 
 //  Cannot find module 'nativescript-socketio'.
import SocketIO = require('nativescript-socketio');

I think it's because I'm using the typescript and the plugin has not nativescript-socketio.d.ts with implementation.

Thks.

triniwiz commented 8 years ago

Ok good to know still not sure why npm is giving you problems i'll add that soon