Open solodov-dev opened 1 year ago
Have the same issue.
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.
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/...
├── ...
└── ...
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.
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):
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 thedist/packages...
folder. Also there is no index.js file in thedist/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.Any help would be appreciated ( I'm trying to build this thing for 3 days already