nstudio / xplat

Cross-platform (xplat) tools for Nx workspaces.
MIT License
366 stars 52 forks source link

Unable to create Angular web app #308

Open nx-irvin opened 2 years ago

nx-irvin commented 2 years ago

I'm trying to create a web a app following the getting started steps. I managed to create an Ionic + Angular App, but when i try the same steps with web + angular it doesn't work. I get the following messages:

Error: Could not find an NgModule. Use the skip-import option to skip importing in NgModule. at findModule (C:\na\dvlp\wks2021\nexus-monorepo\node_modules\@schematics\angular\utility\find-module.js:81:11) at findModuleFromOptions (C:\na\dvlp\wks2021\nexus-monorepo\node_modules\@schematics\angular\utility\find-module.js:26:38) at C:\na\dvlp\wks2021\nexus-monorepo\node_modules\@schematics\angular\component\index.js:105:66 Error: Could not find an NgModule. Use the skip-import option to skip importing in NgModule. at findModule (C:\na\dvlp\wks2021\nexus-monorepo\node_modules\@schematics\angular\utility\find-module.js:81:11) at findModuleFromOptions (C:\na\dvlp\wks2021\nexus-monorepo\node_modules\@schematics\angular\utility\find-module.js:26:38)

Steps:

nx generate app √ What name would you like for this app? · my-app-web √ What type of app would like to create? · web √ In which directory should the app be generated? 'apps' √ Would you like to configure routing for this app? (Y/n) · true √ Which frontend framework should it use? · angular √ Use xplat supporting architecture? (Y/n) · true

NathanWalker commented 2 years ago

@nx-irvin thanks for the report. I just tried this here:

npx create-nx-workspace@latest

> sample
// let dependencies install and finish initial setup

> cd sample
> npm install @nstudio/xplat -D
> npx nx g app
> myapp
> web
> npx nx run web-myapp:serve
// works

You may try leaving web out of the app name since xplat adds the platform naming conventions itself - that may be interfering with the generators.

nx-irvin commented 2 years ago

Hi! Thanx for the quick response. I tried without the word web and I get the same error.

NathanWalker commented 2 years ago

When you can run “ng —version”

Sounds like there could be global angular versions installed which may be having an effect?

nx-irvin commented 2 years ago

Ok, this is what i got:

Angular CLI: 13.2.6 Node: 14.18.1 Package Manager: npm 8.5.4 OS: win32 x64

Angular: undefined ...

Package Version

@angular-devkit/architect 0.1302.6 (cli-only) @angular-devkit/core 13.3.5 @angular-devkit/schematics 13.3.5 @schematics/angular 13.3.5 typescript 4.6.4

NathanWalker commented 2 years ago

Thanks could be your node version. Would generally recommend 15+ but I would switch to using node 16, 17 or 18. I’m using node 18 with npm 8.10.0 myself (latest of everything).

nx-irvin commented 2 years ago

I will update to version 18 and 8.10.0 and let you know.

nx-irvin commented 2 years ago

I´m still getting the same error. I tried in a different PC installing all from scratch and the same result.

NathanWalker commented 2 years ago

I think it may be due to a Nx preset you may be using, when doing: npx create-nx-workspace@latest Then naming the workspace, after that it asks what preset you’d like to use - are you choosing Angular? If so that is likely the issue. You would want to choose empty or no preset - I believe they call it simply “apps” the first one in list.

NathanWalker commented 2 years ago

@nx-irvin lemme know if the preset was it when you get a chance; pretty curious here.

nx-irvin commented 2 years ago

Apparently it was due to the Nx 'apps' preset. I was finally able to go around this issue using the 'angular' preset.

NathanWalker commented 2 years ago

Interesting I see exact opposite of that here (wonder if Windows has some affect here) - we’ll leave this open until more finite conclusions can be drawn. Thanks for mentioning this and that there is a solution for it.