NathanaelA / nativescript-websockets

Websockets for NativeScript
83 stars 43 forks source link

Module not found: Error: Can't resolve './websockets-base' for "@master.technology/websockets" #96

Open harsh2304 opened 2 years ago

harsh2304 commented 2 years ago

I am trying to move from "nativescript/websockets" to @master.technology/websockets. I have successfully installed @master.technology/websockets and uninstalled "nativescript/websockets" But I am getting below error during build phase ("tns build android"). I am using nativescript-angular framework. I am using tns-android version 6.5.3

Error: ERROR in ../node_modules/@master.technology/websockets/websockets.js Module not found: Error: Can't resolve './websockets-base' in 'C:\Users\username\Gitlab\App\AppName\node_modules\@master.technology\websockets'

Below is my new code (which is giving an error): require('@master.technology/websockets'); //Earlier it was following code, require('nativescript/websockets') and it was working fine this.webSocket = new WebSocket("ws://echo.websocket.org", []); this.webSocket.on('open', () => {}); this.webSocket.on('close', () => {}); this.webSocket.on('error', () => {}); this.webSocket.on('message', () => {});

harsh2304 commented 2 years ago

@NathanaelA : Can you please help me here? Let me know in case you require more details regarding error. Thank you so much in advance.

NathanaelA commented 2 years ago

Have you downloaded the demo and seen if it builds properly?

harsh2304 commented 2 years ago

@NathanaelA : Thank you for your response. Can you please provide me the link for demo?

NathanaelA commented 2 years ago

Its the demo in this repo. Clone the repo, and then try it.

aaflexistax commented 2 years ago

Hi @NathanaelA ,

I am facing the same issue after upgrading. As you suggested I took the demo to check if it is working but it failed with the following:

Preparing project... [webpack-cli] Error: Unknown option '--env.hmr' [webpack-cli] Run 'webpack --help' to see available commands and options Executing webpack failed with exit code 2.

I realised that you require ns8 for the demo to work. I am currently using ns7.

Any suggestions on how to fix this.

Thanks

NathanaelA commented 2 years ago

Just upgrade your nativescript cli. (npm i -g nativescript@latest) The most current NS CLI will build NS 6, 7 & 8 projects.

aaflexistax commented 2 years ago

Yes you were right, thanks for the help.

gayatri-kadam commented 2 years ago

Hi @NathanaelA, I am facing the same issue described in the main issue. I am using "6.4.0" nativescript core version and 6.5.0. nativescrtipt CLI version. Do I need to upgrade to "NS 7 or NS 8 in order to use the plugin? I was able to build the demo project using 8.1.5 nativescript CLI but was unable to use the same in my project.

NathanaelA commented 2 years ago

You would want to upgrade to NS 6.5 as the differences between 6.4 and 6.5 really are just Mainly elimination of bugs.

gayatri-kadam commented 2 years ago

Okay so I updated it to NS 6.5 and it still won't work (got the same error again mentioned in the main issue). I tried running Demo project independently by copying it to another location (out of the folder nativescript-websockets-master) and also changed "@master.technology/websockets": "^2.0.3" in package.json file and tried building it but I got an error:

Error executing Static Binding Generator: Couldn't find 'C:\Users\gkadam\Pictures\nativescript-websockets-master\demo\platforms\android\build-tools\sbg-bindings.txt' bindings input file. Most probably there's an error in the JS Parser execution. You can run JS Parser with verbose logging by executing "node 'C:\Users\gkadam\Pictures\nativescript-websockets-master\demo\platforms\android\build-tools\jsparser\js_parser.js' enableErrorLogging".

@NathanaelA can you please help me here? I am still unable to use "@master.technology/websockets" in my project.

NathanaelA commented 2 years ago

Try doing a ns clean on the project.

gayatri-kadam commented 2 years ago

ns clean gives "Unknown command clean" error on NS 6.5. So I even tried

  1. tns platform remove android and add android
  2. tns platform clean android
  3. npm cache clean --force None of it worked. I am still getting the error mentioned in the main issue.
NathanaelA commented 2 years ago

The platform add/remove is pretty close to a clean.

  1. Have you tried cloning the repo and seeing if the demo works?
  2. Have you tried updating your nativescript cli (npm i -g nativescript@latest)
gayatri-kadam commented 2 years ago
  1. Yes, I have tried running the Demo project, it works fine only with NS cli 8 and nativescript/core version 8. It does not work with NS 6 and 7 (builds with 7 but gives runtime error module not found).

  2. Yes, I also tried updating nativescript cli to the latest version (8.1.5), It still gives this error in my project:

ERROR in ../node_modules/@master.technology/websockets/websockets.js Module not found: Error: Can't resolve './websockets-base' in 'C:\Users\gkadam\Documents\myproject\node_modules\@master.technology\websockets' @ ../node_modules/@master.technology/websockets/websockets.js 11:25-53 @ ./app/core/services/web-socket.service.ts @ ./app/core/core.module.ts @ ./app/app.module.ts @ ./main.ts Webpack compilation complete. Executing webpack failed with exit code 2.

Can you confirm if this plugin is valid for NS 6 and 7?

NathanaelA commented 2 years ago

The plugin should work fine for both NS 6 and up. However, it must be a NS 6 where the webpack and core modules knows what @nativescript/core is.

When I have a chance (might be several weeks, since doing anything with this -- is all unpaid, so it has a very low priority) --- I'll clone this repo directly and have it point to the released plugins rather than the relative link and see if I can duplicate the issue.