neutralinojs-cli icon indicating copy to clipboard operation
neutralinojs-cli copied to clipboard

NL_* vars not set in client when run with frontend-lib-dev flag

Open benoneal opened this issue 2 years ago • 14 comments

Expected Behavior
All NL_* global vars should be set in the client regardless of cli flags.

Actual Behavior
None of the NL_* global vars are set in the client when run with --frontend-lib-dev flag, despite being present when run with no flag. This results in none of the native API or any server-dependent Neutralino functionality working from the client, as the websocket cannot connect due to undefined NL_PORT.

This makes development significantly slower and more frustrating as the client has to be re-built and the app re-run to test any functionality dependent on these features.

Steps to Reproduce the Problem

  1. Run a test app with neu run
  2. Confirm that NL_PORT (or any NL_ prefixed global vars) is set either via enabling the inspector or having the client render it
  3. Run the same app with neu run --frontend-lib-dev
  4. Observe that NL_PORT (and all NL_* vars) is now undefined (and the websocket connection will have errored, rendering Neutralino broken entirely)

Specifications

  • NeutralinoJs Version: 4.4.0
  • NeutralinoJs CLI version: 9.2.0
  • Platform: macOS Monterey 12.1

benoneal avatar Mar 22 '22 23:03 benoneal

I Tried to recreate this problem, but seems like it works fine on Linux. Can you share your code if possible?

pegvin avatar Mar 23 '22 00:03 pegvin

I Tried to recreate this problem, but seems like it works fine on Linux. Can you share your code if possible?

App built from this: https://github.com/codezri/neutralinojs-react repo linked to from the official docs here: https://neutralino.js.org/docs/how-to/use-a-frontend-library

benoneal avatar Mar 23 '22 02:03 benoneal

Can you try this template and see if this works or not: https://github.com/DEVLOPRR/react-neutralino/

pegvin avatar Mar 23 '22 02:03 pegvin

Just tested, and it does not work.

Screenshot of inspector when run with flag: Screen Shot 2022-03-23 at 2 40 09 pm

Screenshot when run without flag (and obviously without live reloading): Screen Shot 2022-03-23 at 9 29 51 am

benoneal avatar Mar 23 '22 04:03 benoneal

@DEVLOPRR It seems unlikely to me that this is an OS-specific issue. When you test that react-neutralino repo you linked, run with neu run --frontend-lib-dev, are the NL_* variables declared in the global scope for you? Does the websocket connect to the neutralino backend?

benoneal avatar Mar 30 '22 00:03 benoneal

Everything works fine for me, not sure why it's occurring, but passing this issue to Devs who have mac os

pegvin avatar Mar 30 '22 00:03 pegvin

I have the same problem when I tried to create an app by doc https://neutralino.js.org/docs/how-to/use-a-frontend-library And on both repos with react examples.

Mac M1, MacOS 12.2.1

bragovo avatar Apr 01 '22 14:04 bragovo

Can we please get some macOS dev eyes on this? Development is high friction when the only way to test any change is a complete build and restart of the app.

benoneal avatar Apr 18 '22 23:04 benoneal

Hi everyone I am here to add that it is not only MacOS issue... I have same problem... OS info: OS: Linux Distro: Arch/Garuda Linux Kernel Version: 5.19.13 (x86_64) NEU-CLI version:

--- Global ---
neu CLI: v9.3.1

--- Project: **Censored** (js.neutralino.zero) ---
Neutralinojs binaries: v4.7.0
Neutralinojs client: v3.6.0

Tested repos: codezri/neutralinojs-react DEVLOPRR/react-neutralino Self builded by tutorial on Neutralino Docs

Result: NL_* variables appear when using neu run command, but not when neu run --frontend-lib-dev

mkikets99 avatar Oct 14 '22 19:10 mkikets99

Have you guys tried to configure the Config Options "patchFile" and "devUrl" ? Eg: image

maxlkatze avatar Nov 14 '22 14:11 maxlkatze

Have you guys tried to configure the Config Options "patchFile" and "devUrl" ? Eg: image

yup, and that's the catch... It is not working somehow

mkikets99 avatar Nov 15 '22 09:11 mkikets99

Do you get the log output for the hotfix being applied?

maxlkatze avatar Nov 16 '22 07:11 maxlkatze

I created a little patch that changes the localhost to 0.0.0.0 after installing the module, it helped me to get the frontendLibrary to work. If you want to give it a try: patch_install.js

maxlkatze avatar Nov 17 '22 09:11 maxlkatze

You have to install neutralino as a dev dependency like: npm install --save-dev @neutralinojs/neu

or you can change the url by hand if you installed globally, the script will only change the dev dependency though

maxlkatze avatar Nov 17 '22 09:11 maxlkatze

Please update the neu CLI program. Now we don't use the --frontend-lib-dev flag and implement a better integration with frontend library development servers :tada:

shalithasuranga avatar May 06 '24 12:05 shalithasuranga