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

Wrong path when generating new apps/libs on windows #250

Closed
probert94 opened this issue Jan 31, 2018 · 9 comments
Closed

Wrong path when generating new apps/libs on windows #250

probert94 opened this issue Jan 31, 2018 · 9 comments
Labels

Comments

@probert94
Copy link

Note:
I opened an Issue in @angular/cli: angular/angular-cli#9444
but it has been closed as an Issue of nrwl/nx, not angular/cli.
Therefore I post it again here.

Since some time I am using nrwl/nx to manage multiple apps in an Angular-CLI project.
The structure of a project usually looks like this:

- apps
-- app1
--- e2e
--- src
-- app2
--- e2e
--- src
- libs
-- lib1

However, I noticed, that when I generate a new app using ng generate app app2, it generates the following structure:

- apps
-- app1
--- e2e
--- src
-- app2
--- e2e
--- apps
---- app1
----- src
- libs
-- lib1

I have been searching for this issue in nrwl/nx and I found a few related Issues:
#131
#140

However they all point to angular/angular-cli#7960 which already is closed, so thats why I opened a new Issue.

Versions

Angular CLI: 1.6.6
Node: 8.5.0
OS: win32 x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

@angular/cdk: 5.1.0
@angular/cli: 1.6.6
@angular/flex-layout: 2.0.0-beta.12
@angular/material: 5.1.0
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • Create a new Angular-CLI project (ng new demo)
  • Navigate into the project (cd .\demo\)
  • Install @nrwl/schematics as a devDependency (npm i -D @nrwl/schematics)
  • Convert the project into a @nrwl/nx workspace using ng g workspace demo --collection=@nrwl/schematics
  • Remove @angular/cli "file" from dependencies in "package.json" (version 1.6.6 is used in the devDependencies)
  • Run npm i -D @angular-devkit/[email protected] (see nx graph doesn't recognise "appsDir" as apps #9374 for more details)
  • Run npm install to add additional dependencies
  • Generate a new app using ng g app demo2

Observed behavior

  create apps/demo2/e2e/app.e2e-spec.ts (269 bytes)
  create apps/demo2/e2e/app.po.ts (201 bytes)
  create apps/demo2/e2e/tsconfig.e2e.json (391 bytes)
  create apps/demo2/apps/demo/src/assets/nx-logo.png (71592 bytes)
  create apps/demo2/apps/demo/src/assets/.gitkeep (0 bytes)
  create apps/demo2/apps/demo/src/environments/environment.prod.ts (51 bytes)
  create apps/demo2/apps/demo/src/environments/environment.ts (387 bytes)
  create apps/demo2/apps/demo/src/favicon.ico (5430 bytes)
  create apps/demo2/apps/demo/src/index.html (291 bytes)
  create apps/demo2/apps/demo/src/main.ts (370 bytes)
  create apps/demo2/apps/demo/src/polyfills.ts (2667 bytes)
  create apps/demo2/apps/demo/src/styles.css (80 bytes)
  create apps/demo2/apps/demo/src/tsconfig.app.json (294 bytes)
  create apps/demo2/apps/demo/src/app/app.module.ts (342 bytes)
  create apps/demo2/apps/demo/src/app/app.component.html (520 bytes)
  create apps/demo2/apps/demo/src/app/app.component.spec.ts (607 bytes)
  create apps/demo2/apps/demo/src/app/app.component.ts (258 bytes)
  create apps/demo2/apps/demo/src/app/app.component.css (0 bytes)
  update .angular-cli.json (2448 bytes)

Note that the src of the newly generated app lies under apps/demo2/apps/demo instead of apps/demo2.

Desired behavior

The src of the newly generated app should be in apps/demo2, so that the structure is the same as in the first app.

Mention any other details that might be useful (optional)

If you don't execute step 5 (Remove angular/cli "file" from dependencies in "package.json") it is using the @angular/cli version 1.6.0 from the .angular_cli.tgz-File. With this version, everything seems to work just fine.
So it seems like nrwl/nx does not work well with newer angular/cli.

@phl3x0r
Copy link

phl3x0r commented Feb 5, 2018

See also #22

@dpalita
Copy link

dpalita commented Feb 7, 2018

I also face this issue on macos with cli 1.6.7, and resetting "@angular/cli": "file:.angular_cli165.tgz" (copied from a new nx workspace) made it work.

@probert94
Copy link
Author

@dpalita thats because of the version of the .tgz file I guess. If you use the same version installed normaly it works too.

@dpalita
Copy link

dpalita commented Feb 7, 2018

@Springrbua yes I suppose so, I was just confirming your comment "it seems like nrwl/nx does not work well with newer angular/cli."
By the way, thanks for finding that out!

@probert94
Copy link
Author

@dpalita as you are working with a file named .angular_cli165.tgz, I suppose it's Angular-CLI version 1.6.5. Can you confirm that by executing ng --version?
If thats the case, the problem started with version 1.6.6.

@dpalita
Copy link

dpalita commented Feb 7, 2018

Well, ng --version returns 1.6.5... but:
-"@angular/cli": "1.6.5" => libs/tete/apps/aphrodite/src/tete.module.spec.ts
-"@angular/cli": "file:.angular_cli165.tgz" => libs/titi/src/titi.module.spec.ts

My global @angular/cli version is 1.6.7 (but shouldn't be used, I get the "version mismatch" warning), in both cases ng version is 1.6.5... The only thing I did between the changes in package.json is yarn install

I do not understand what difference between the 2 modes leads to a different behavior. In case that helps, I took this tgz from a clean create-nx-workspace (V0.7.3).

@probert94
Copy link
Author

probert94 commented Feb 7, 2018

Maybe the file is a patched version of angular/cli?

@probert94
Copy link
Author

As stated in Issue 140, this is a bug in Angular-CLI, which should be fixed in the version 1.7.0.
Until then, the .tgz-File, which comes with nrwl/nx should be used, as it contains the bugfix.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants