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

Undefined workspace while trying to generate nx-electron app. #171

Closed
broken opened this issue Jun 13, 2022 · 6 comments
Closed

Undefined workspace while trying to generate nx-electron app. #171

broken opened this issue Jun 13, 2022 · 6 comments

Comments

@broken
Copy link

broken commented Jun 13, 2022

Describe the bug
Error while trying to generate an nx-electron app.

To Reproduce
Steps to reproduce the behavior:

npx create-nx-workspace@13 --preset=core
# Used workspace name 'test'
cd test
npm install -D @nrwl/web
nx g @nrwl/web:app fe
npm install -D nx-electron
nx g nx-electron:app app --frontendProject=fe
# Using . as the directory, but I tried other values as well. I didn't see much info on what is expected here.

The error

✔ In which directory should the electron application be generated? · .
TypeError: Cannot read properties of undefined (reading 'targets')
    at /Users/dogatech/Development/src/test/node_modules/nx/src/config/workspaces.js:240:27
    at Array.forEach (<anonymous>)
    at toOldFormatOrNull (/Users/dogatech/Development/src/test/node_modules/nx/src/config/workspaces.js:236:37)
    at MapSubscriber.project (/Users/dogatech/Development/src/test/node_modules/nx/src/adapter/ngcli-adapter.js:181:82)
    at MapSubscriber._next (/Users/dogatech/Development/src/test/node_modules/rxjs/internal/operators/map.js:49:35)
    at MapSubscriber.Subscriber.next (/Users/dogatech/Development/src/test/node_modules/rxjs/internal/Subscriber.js:66:18)
    at MapSubscriber._next (/Users/dogatech/Development/src/test/node_modules/rxjs/internal/operators/map.js:55:26)
    at MapSubscriber.Subscriber.next (/Users/dogatech/Development/src/test/node_modules/rxjs/internal/Subscriber.js:66:18)
    at DefaultIfEmptySubscriber._complete (/Users/dogatech/Development/src/test/node_modules/rxjs/internal/operators/defaultIfEmpty.js:45:30)
    at DefaultIfEmptySubscriber.Subscriber.complete (/Users/dogatech/Development/src/test/node_modules/rxjs/internal/Subscriber.js:78:18)
Cannot read properties of undefined (reading 'targets')

Desktop (please complete the following information):

  • OS: OSX 11.6.5
  • Nx Electron Version: nx-electron@13.2.1
  • Nx Version: nx@13.10.5
  • NPM Version: npm@8.10.0
@jieey1140
Copy link

jieey1140 commented Jun 13, 2022

I also get the same error as above T.T

@bennymeg
Copy link
Owner

bennymeg commented Aug 29, 2022

Did you try to press Enter without entering any value?

@broken
Copy link
Author

broken commented Sep 20, 2022

I did. I tried no value, ., the full path to the packages dir, to a new directory, etc. - all got the same error.

I just tried again, creating a new v13.10.6 workspace, and still receive the error.

@broken
Copy link
Author

broken commented Sep 21, 2022

I just tested this on a Linux machine and got the same error. However, I did some digging online and found this (edit: likely unrelated) issue. I rolled back my version of nx to 13.4.5 and was able to run the command successfully.

I haven't tested any more up to just seeing it complete, so don't know which version of nx is the first to have this problem, but wanted to post this reply to help any others experiencing the same problem.

@broken
Copy link
Author

broken commented Sep 21, 2022

After doing some more testing, it looks like minor version 10 is when the failure started. NX version 13.9.7 (and all before I tried) did not have a problem, but version 13.10.0 is the first that began showing that error.

My guess (with absolutely no experience with nx or nx-electron) is this pull which removed workspace.json is the culprit. With no workspace.json, the generator for nx-electron cannot find the frontendProject specified.

Yep. I just added a simple workspace.json that would have been there from earlier version and the nx-electron generator using version 13.10.0 of nx now completes without error.

{
  "version": 2,
  "projects": {
    "fe": "packages/fe",
    "fe-e2e": "packages/fe-e2e"
  }
}

@bennymeg I'm not familiar enough to know how this should be handled - in nx, nx-electron, or documentation, so I'm going to leave how to proceed to you.

@bennymeg
Copy link
Owner

I see.
You might need to be using one of the new presets (like apps) from now on.
This is an NX behavior that I cannot change, I will add a section about it in the docs.

@bennymeg bennymeg closed this as completed May 2, 2023
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

3 participants