Nx: Windows: Generating library components gets incorrect path

Created on 5 Dec 2017  路  5Comments  路  Source: nrwl/nx

Global Angular CLI: 1.5.0
Node: 6.12.0

Workspace created by running curl -fsSL https://raw.githubusercontent.com/nrwl/nx/master/packages/install/install.sh | bash -s nxTest in a Git Bash window.

Following along with the Nx Workspace guide, I first generated an app and a lib:

ng generate app myapp --routing
ng generate lib mymodule

I then did a dry run of creating a component in the library:

$ ng generate component myButton --app=mymodule --dry-run
  create libs/mymodule/src/libs/mymodule/src/my-button/my-button.component.html (28 bytes)
  create libs/mymodule/src/libs/mymodule/src/my-button/my-button.component.spec.ts (643 bytes)
  create libs/mymodule/src/libs/mymodule/src/my-button/my-button.component.ts (280 bytes)
  create libs/mymodule/src/libs/mymodule/src/my-button/my-button.component.css (0 bytes)
  update libs/mymodule/src/mymodule.module.ts (288 bytes)

NOTE: Run with "dry run" no changes were made.

Notice that instead of creating the component under libs/mymodule/srsc/my-button, instead the generated file path has an extra libs/mymodule in it.

Running without the --dry-run option results in the files being generated as indicated, with the extra libs/mymodule in the path.

In Nx 0.1.0, the commands to create the library resulted in a root in .angular-cli.json for the library module like libs\\mymodule\\src on Windows, where the same root would be libs/mymodule/src in Linux/MacOS.

Now in Nx 0.3.0, the command creates a root of libs/mymodule/src on Windows as well.

If I manually change the root to use double back-slashes as had been generated in Nx 0.1.0, running ng generate component myButton properly creates the files under libs/mymodule/src/my-button without the extra path elements.

What I would expect is that the root would be created consistently in all operating systems (as is currently the case for Nx 0.3.0) and that generating library components on Windows would not create the extra path elements.

bug

All 5 comments

Seems this is the same as #131 where it was mentioned that angular/angular-cli#7960 addresses the issue. Wouldn't that mean that nrwl/fix-cli-build needs to be updated?

I read through angular/angular-cli#7960, which said that the fix to the CLI was addressed in angular/angular-cli#8559. Those changes have been merged into CLI v1.6.0. Given that, I tried an experiment of changing the devDependency in my test project from "@ angular/cli": "nrwl/fix-cli-build" to "@ angular/cli": "~1.6.0".

Unfortunately, the behavior of ng generate component myButton --app=mymodule --dry-run appears unchanged.

Having same issue

I am now facing the same issue, when generating new apps/libs.
The result of ng g app TestApp in a multi-app-project is:

- test-app
-- apps
--- name-of-first-app
---- src

Instead of:

- test-app
-- src

I am using @angular/cli 1.6.6 and @nrwl/nx 0.6.19.

The nested structure is due to a bug in the CLI.

  • Create a new project using create-nx-workspace.
  • Open package.json, and you will see "@angular/cli" is set to ".angular_cli165.tgz". You need to use this version of the CLI instead of 1.6.x. The .tgz version has the bug fixed.
  • This should not be necessary when CLI 1.7.0 comes out.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dereklin picture dereklin  路  3Comments

about-code picture about-code  路  3Comments

vimalraj-a picture vimalraj-a  路  3Comments

joelmuskwe picture joelmuskwe  路  3Comments

danieldanielecki picture danieldanielecki  路  3Comments