Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run <app-name>-electron:make #247

Open
solodov-dev opened this issue Sep 29, 2023 · 3 comments
Open

Cannot run <app-name>-electron:make #247

solodov-dev opened this issue Sep 29, 2023 · 3 comments

Comments

@solodov-dev
Copy link

Describe the bug
After upgrading from v.13 to v.16 I cannot build the electron app.

Expected behavior
Running nx run <app-name>-electron:make makes an electron executable.

Desktop (please complete the following information):

  • OS: Manjaro Linux
  • Nx Electron Version [16.6.0]

Additional context
I've been assigned to an existing project which uses nx, react and electron. The project was running nx 13. I've upgraded everything to v.16. Nx electron was upgraded to v16.0.0-beta.1.

After upgrading I cannot run nx run <app-name>-electron:make. I am getting this error:
ENOENT no such file or directory '/home/<user>/code/<project-dir>/dist/packages/<app-name>-electron/index.js'.

The electron:build command creates a folder dist/apps/<app-name>-electron and not the dist/packages... folder. Also there is no index.js file in the dist/apps/<app-name>-electron folder, but a main.js file instead. I understand that I have to set some options for the electron:make command, but setting these options in maker.options.json doesn't help.

"directories":{
   "app": "apps/<app-name>-electron",
   "buildResources": "apps/<app-name>-electron"
 },

Any help would be appreciated ( I'm trying to build this thing for 3 days already

@6matko
Copy link

6matko commented Oct 7, 2023

Have the same issue.

@octadecimal
Copy link

For both your renderer and main electron projects, try adjusting the outputPath field of project.json in both projects to be something like:

    "outputPath": "dist/apps/myproject-electron",

instead of:

    "outputPath": "dist/apps/myproject/electron",

That way they're both emitting to the root dist/apps directory without any further nesting. I'm not sure if it's the same issue you're having, but it sounds similar. I needed to do this in order for :make to work.

@KaraboMolemane
Copy link

Hi,

I also struggled with similar problem on nx-electron": "16.2.0 for weeks. I am not sure if my solution will help, but here goes...

We had the following set up

<workspace name>/
├── apps/
│   ├── frontend/
│   │   ├── react-app/
│   │   └── electron-app/
│   └── backend/...
├── ...
└── ...
  • Still debating with my team members to move electron to backend :D but anyways...

When created the frontEndApp(built on React) and the electronApp, nx-electron will asked if you want to use the derived name or as provided. We initially went with derived which would give the two apps names based on their path as follows:

The names we provided were:

frontEndApp: react-app
electronApp: electron-app

the final derived name given to the apps were:

frontEndApp: frontend-react-app
electronApp: frontend-electron-app

So when we run <app-name>-electron:make, the app looks for the compiled files inside

dist/apps/frontend/frontend-electron-app/

instead of:

dist/apps/frontend/electron-app/

Clearly the first directory does not exist and I would get the exact same error that you are getting (ENOENT no such file or directory... ).

The problem here is the derived name. So I renamed both my frontEndApp(built on React) and the electronApp from

frontEndApp: frontend-react-app
electronApp: frontend-electron-app

to

frontEndApp: react-app
electronApp: electron-app

and all other references in the project should be updated. For example, one of the changes we had to make in the electron-app's project.json file was as follows:
from:

   "make": {
     "executor": "nx-electron:make",
     "options": {
       "name": "frontend-electron-app",
       "frontendProject": "frontend-react-app",
       "sourcePath": "dist/apps",
       "outputPath": "dist/executables"

to

   "make": {
     "executor": "nx-electron:make",
     "options": {
       "name": electron-app",
       "frontendProject": "react-app",
       "sourcePath": "dist/apps/frontend",
       "outputPath": "dist/executables"

The other option is to create the apps from scratch and select the as provided option when providing the app names. As previously stated, my problem was caused by the derived name option. While working on nx-18, I saw a notification stating that nx-19 will no longer allow the derived name option.

I hope all this makes sense, Let me know if you need any additional information or if it solves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants