nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.28k stars 2.32k forks source link

@nx/angular:lib generator doubles path of generated components #22394

Closed montella1507 closed 6 months ago

montella1507 commented 9 months ago

NX Console: 1.15.1

CWD: libs/portal/shared COMMAND: nx g @nx/angular:library --name=wtf --projectNameAndRootFormat=as-provided --no-interactive --dry-run

ERROR: The provided directory resolved relative to the current working directory "libs/portal/shared/libs/portal/shared/wtf/src/lib/wtf" does not exist under any project root.

Why it there "libs/portal/shared/" two times in the path?

Similar when "derived" is used:

CWD: libs/portal/shared COMMAND: nx g @nx/angular:library --name=wtf --projectNameAndRootFormat=derived --no-interactive --dry-run

ERROR: The provided directory resolved relative to the current working directory "libs/portal/shared/libs/wtf/src/lib/wtf" does not exist under any project root.

Now the path looks correct, but errors is thrown anyway.

Error is the same when "nx g @nx/angular:library --name=wtf --no-interactive --dry-run" is used (no projectNameAndRootFormat switch.

Only way how to generate library atm in our monorepo is to execute (cwd) in root and set it via directory + derived: nx g @nx/angular:library --name=wtf --buildable=true --directory=libs/shared --projectNameAndRootFormat=derived --no-interactive --dry-run

RESULT

UPDATE nx.json
CREATE libs/shared/wtf/project.json
CREATE libs/shared/wtf/README.md
CREATE libs/shared/wtf/ng-package.json
CREATE libs/shared/wtf/package.json
CREATE libs/shared/wtf/tsconfig.json
CREATE libs/shared/wtf/tsconfig.lib.json
CREATE libs/shared/wtf/tsconfig.lib.prod.json
CREATE libs/shared/wtf/src/index.ts
CREATE libs/shared/wtf/src/lib/shared-wtf/shared-wtf.component.scss
CREATE libs/shared/wtf/src/lib/shared-wtf/shared-wtf.component.html
CREATE libs/shared/wtf/src/lib/shared-wtf/shared-wtf.component.ts
CREATE libs/shared/wtf/.eslintrc.json

NX,json { "$schema": "./node_modules/nx/schemas/nx-schema.json", "affected": { "defaultBase": "master" }, "cli": { "packageManager": "yarn" }, "targetDefaults": { "build": { "dependsOn": ["^build"], "inputs": ["production", "^production"], "cache": true }, "lint": { "inputs": ["default", "{workspaceRoot}/.eslintrc.json"], "cache": true }, "build-storybook": { "inputs": [ "default", "^production", "{workspaceRoot}/.storybook//*", "{projectRoot}/.storybook/*/", "{projectRoot}/tsconfig.storybook.json" ], "cache": true }, "e2e": { "cache": true }, "@nx/jest:jest": { "cache": true, "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"], "options": { "passWithNoTests": true }, "configurations": { "ci": { "ci": true, "codeCoverage": true } } } }, "generators": { "@nx/angular:application": { "style": "scss", "linter": "eslint", "unitTestRunner": "none", "e2eTestRunner": "cypress" }, "@nx/angular:library": { "style": "scss", "linter": "eslint", "unitTestRunner": "none", "buildable": true, "changeDetection": "OnPush", "displayBlock": true, "setParserOptionsProject": true, "skipModule": true, "skipTests": true, "strict": true }, "@nx/angular:component": { "style": "scss", "changeDetection": "OnPush", "standalone": true, "displayBlock": true, "nameAndDirectoryFormat": "derived", "skipTests": true }, "@nx/web:application": { "style": "scss", "linter": "eslint", "unitTestRunner": "jest", "e2eTestRunner": "cypress" }, "@nx/web:library": { "style": "scss", "linter": "eslint", "unitTestRunner": "jest" } }, "defaultProject": "portal", "namedInputs": { "default": ["{projectRoot}//*", "sharedGlobals"], "sharedGlobals": [], "production": [ "default", "!{projectRoot}/.eslintrc.json", "!{projectRoot}/.storybook/*/", "!{projectRoot}/*/.stories.@(js|jsx|ts|tsx|mdx)", "!{projectRoot}/tsconfig.storybook.json", "!{projectRoot}/src/test-setup.[jt]s" ] } }

Nx Version:

MaxKless commented 9 months ago

that's really weird... I will have a look! Can you paste your 'nx report' results?

montella1507 commented 9 months ago
Convert compiler options from json failed, No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["../../../../node_modules/@angular/localize/init/index.d.ts"]' and 'exclude' paths were '["node_modules","tmp"]'.

 >  NX   Report complete - copy this into the issue template

   Node   : 20.9.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx                 : 17.1.3
   @nx/js             : 17.1.3
   @nx/jest           : 17.1.3
   @nx/linter         : 17.1.3
   @nx/eslint         : 17.1.3
   @nx/workspace      : 17.1.3
   @nx/angular        : 17.1.3
   @nx/cypress        : 17.1.3
   @nx/devkit         : 17.1.3
   @nx/eslint-plugin  : 17.1.3
   @nx/plugin         : 17.1.3
   @nx/storybook      : 17.1.3
   @nrwl/tao          : 17.1.3
   @nx/web            : 17.1.3
   @nx/webpack        : 17.1.3
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @ngrx/component       : 17.0.1
   @ngrx/component-store : 17.0.1
   @ngrx/effects         : 17.0.1
   @ngrx/router-store    : 17.0.1
   @ngrx/store           : 17.0.1
   @ngrx/store-devtools  : 17.0.1
   @storybook/angular    : 7.6.3
   ngxtension            : 1.4.0
montella1507 commented 9 months ago

@MaxKless i can give you remote control to my pc if you are willing to :-)

MaxKless commented 8 months ago

Hey! I'm working on some improvements in this area right now that should be merged to master this week. Let's revisit this issue once the changes are in.

montella1507 commented 8 months ago

Ok :-)

nhack commented 8 months ago

Any updates on this?

I have the same issue.

Node : 18.17.1 OS : darwin-x64 npm : 9.6.7

nx : 17.2.3 @nx/js : 17.2.3 @nx/jest : 17.2.3 @nx/linter : 17.2.3 @nx/eslint : 17.2.3 @nx/workspace : 17.2.3 @nx/angular : 17.2.3 @nx/cypress : 17.2.3 @nx/devkit : 17.2.3 @nx/eslint-plugin : 17.2.3 @nx/storybook : 17.2.3 @nrwl/tao : 17.2.3 @nx/web : 17.2.3 @nx/webpack : 17.2.3 typescript : 5.2.2

Community plugins: @ngrx/effects : 17.0.1 @ngrx/router-store : 17.0.1 @ngrx/schematics : 17.0.1 @ngrx/store : 17.0.1 @ngrx/store-devtools : 17.0.1 @nxrocks/nx-spring-boot : 9.2.1 @storybook/angular : 7.6.4 angular-auth-oidc-client : 16.0.1

MaxKless commented 8 months ago

I just released a new version, can you try again?

montella1507 commented 8 months ago

Webstorm, 1.16.1 plugin. image

As-provided: "libs/shared/libs/shared/my/src/lib/my"

still doubling path.

Same for derived:

/nx g @nx/angular:library --name=my --projectNameAndRootFormat=derived --no-interactive --dry-run

>  NX  Generating @nx/angular:library

 >  NX   The provided directory resolved relative to the current working directory "libs/shared/libs/my/src/lib/my" does not exist under any project root. Please make sure to navigate to a location or provide a directory that exists under a project root.

   Pass --verbose to see the stacktrace.

image

montella1507 commented 8 months ago

@MaxKless 1.17.0 still not available https://plugins.jetbrains.com/plugin/21060-nx-console

so i will wait.

Nisalay commented 8 months ago

I just released a new version, can you try again?

plugin version: 1.17.0 (WebStorm) Still have a problem IMAGE 2024-01-18 10:37:20

But if I run this command manually without the plugin I get the same problem:

Снимок экрана 2024-01-18 в 10 44 49 Снимок экрана 2024-01-18 в 11 08 15
montella1507 commented 8 months ago

So it is not problem with nx-console, but with schematics ?

Nisalay commented 8 months ago

So it is not problem with nx-console, but with schematics ?

I guess, but probably @MaxKless has something to say

pliersch commented 7 months ago

same problem. creating angular apps works, but not libs. v1.18.0 (Webstorm 2023.3.3)

MaxKless commented 6 months ago

So after digging in a bit I can confirm that this has nothing to do with Nx Console and is a problem with the @nx/angular:lib generator. I'm moving this issue over to the main nx repo and pinging someone.

github-actions[bot] commented 5 months ago

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.