nx-electron icon indicating copy to clipboard operation
nx-electron copied to clipboard

Upgrade to nx@14

Open r-hannuschka opened this issue 2 years ago • 23 comments

Is your feature request related to a problem? Please describe. github pipeline fail with:

npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm ERR! code 1
npm ERR! path /home/runner/work/easyBSB/easyBSB/node_modules/nx-electron/node_modules/nx
npm ERR! command failed
npm ERR! command sh -c node ./bin/init
npm ERR! >  NX   Cannot read properties of undefined (reading 'endsWith')

...

This happens for the simple reason we have installed nx@14 but nx-electron use nx@13

Describe the solution you'd like upgrade deps to [email protected]

Describe alternatives you've considered As workarround what helps for now is to override inside the package.json the deps of nx-electron and it seems to work.

{
  ...
  },
  "overrides": {
    ...
    "nx-electron": {
      "@nrwl/devkit": "14.1.9",
      "@nrwl/workspace": "$@nrwl/workspace"
    }
  }
}

Additional context Fun part here, we test this on multiple local systems it was working. Because maybe npm cache or something else i do not know. It only failed inside ci pipeline and gitpod.

r-hannuschka avatar May 29 '22 21:05 r-hannuschka

Problem seems to be solved with version 13.2.1 so i think i can close this issue. Thx for the good work :)

r-hannuschka avatar Jun 02 '22 08:06 r-hannuschka

I'm still having the same problem even with the v13.2.1 with nx v14.1.9. Anyone an Idea what else could be the problem?

lailo avatar Jun 02 '22 13:06 lailo

yeah was a mistake forgot to run npm i again, so it takes the wrong package-lock.json with nx@14 as depdenceny. It currently seems only to work if we override this inside the package.json.

r-hannuschka avatar Jun 02 '22 23:06 r-hannuschka

@lailo The problem in my case was the missing root property in the project.json files. For instance, if the sourceRoot is apps/my-app/src, you need to add the root property apps/my-app.

It works fine after adding this property. I am using version 2 of the angular.json file.

orestisioakeimidis avatar Jun 07 '22 05:06 orestisioakeimidis

Has anyone had success with nx@14? Unfortunately, updating npm to v8 to make use of overrides is not an option for me.

Crikey-Mikey avatar Jun 29 '22 01:06 Crikey-Mikey

EDIT: "It's working fine for me out of the box with NX v14."

UPDATE: It was working fine locally but as mentioned it only breaks in my Github Actions CI pipeline.

keypuncherlabs avatar Jul 16 '22 23:07 keypuncherlabs

The overrides solution don't work for me :'( got the same problem on my pipeline

lbAntoine avatar Jul 23 '22 06:07 lbAntoine

Still doesn't work, steps to reproduce

  1. Using nvm to install node v16.17.0
  2. Install nx using npx create-nx-workspace@latest somename (use new workspace for apps option). This creates workspace with version v14.5.8
  3. run npm i -D @nrwl/react
  4. run nx g @nrwl/react:app some app (installed react router and styled-components for style)
  5. run nx build and nx serve to make sure the default react app works
  6. run npm install -D nx-electron, get the following error `.... npm ERR! command failed npm ERR! command sh -c -- node ./bin/init npm ERR! > NX Cannot read properties of undefined (reading 'endsWith')

npm ERR! A complete log of this run can be found in: ...`

Seems like out of the box nx-electron is referring to [email protected]

sngh938 avatar Aug 23 '22 02:08 sngh938

did anybody found solution to this problem. I have the same issue.... but in my case the app is blank and I get a different error image below.

daiky00 avatar Aug 27 '22 15:08 daiky00

Here is the image of the error. Screen Shot 2022-08-27 at 11 40 38 AM

daiky00 avatar Aug 27 '22 15:08 daiky00

The app looks completely blank Screen Shot 2022-08-27 at 11 42 46 AM

daiky00 avatar Aug 27 '22 15:08 daiky00

@daiky00 it looks like the problem is that your front-end hasn't been started, no? it says that electron can't load http://localhost:4200.

sviatoslav-lebediev avatar Aug 29 '22 07:08 sviatoslav-lebediev

@sviatoslav-lebediev I didn't know you needed to start the frontend project though? it works after starting my frontend project in another terminal but that feels weird. is that how is suppose to be? and also I am wondering how is that suppose to work when you deploy the app to production so that people can downloaded it?

daiky00 avatar Aug 29 '22 13:08 daiky00

@daiky00 usually I run it in this way nx run-many --target=serve --projects=cfl-main,cfl-renderer --parallel but I have a few electron apps in the same repo. So I don't know if you can just run your app as nx serve. As for the second question - take a look at the loadMainWindow method. In dev mode, it will load a URL but for the packaged version will load a bundled index.htm

sviatoslav-lebediev avatar Aug 29 '22 14:08 sviatoslav-lebediev

Please use the discussions section for that so other people could take advantage of you conversation. The issues section should be used for bug reports only.

bennymeg avatar Aug 29 '22 14:08 bennymeg

Testing my steps on node v14.17.5, doing the same steps I posted above still no success, npm install -D nx-electron seems to be hanging at

...

[email protected] postinstall /Users/srinath.n/tsc3.0/itshinni-workspace/node_modules/nx-electron/node_modules/nx node ./bin/init

sngh938 avatar Sep 06 '22 01:09 sngh938

Experiencing the same issue, but the "overrides" solution didn't work for me. As a temporary solution, I updated my package.json to have:

"nx-electron": "https://github.com/bennymeg/nx-electron#feature/v14",

Since I noticed there's a v14 branch in the works. This fixed it for me. I wouldn't recommend this for production code, but in my case, it unblocked me for now, and I hope soon enough we have official v14 support.

isaacpalka avatar Sep 18 '22 03:09 isaacpalka

@isaacpalka There is an v14-alpha version on npm.

bennymeg avatar Sep 18 '22 18:09 bennymeg

14.0.0-alpha.1 isn't packaging my front-end app, resulting in a blank window when booting the app. Any ideas on remedying this? My build works perfectly on 13.2.1.

TheMikeSanto avatar Sep 23 '22 14:09 TheMikeSanto

Same issue here, nx-electron works well with nx 14.5.10 but crash at post-install with nx 14.7.13...

alljinx avatar Sep 26 '22 12:09 alljinx

@bennymeg when can we expect v14 upgrade?

dhrn avatar Oct 05 '22 19:10 dhrn

@alljinx nx-electron v13 is only compatible with nx v13? which version are you using? @dhrn once I understand if the alpha is broken or if the problem is version mixing.

bennymeg avatar Oct 07 '22 08:10 bennymeg

@bennymeg nx-electron 13.2.1 and nx 14.5.10 seems to works like a charm in my project...

alljinx avatar Oct 07 '22 08:10 alljinx

@bennymeg When do you expect v14 to drop?

TheMikeSanto avatar Oct 14 '22 21:10 TheMikeSanto

Nx v15 has been released. So I'm starting to worry about being 2 major releases late...

alljinx avatar Oct 16 '22 13:10 alljinx

just curious to know the progress on this @bennymeg

dhrn avatar Nov 06 '22 14:11 dhrn

Released!

bennymeg avatar Feb 01 '23 18:02 bennymeg