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

Generating Angular component fails with invalid path #18805

Closed
1 of 4 tasks
austinw-fineart opened this issue Aug 24, 2023 · 5 comments · Fixed by #18933
Closed
1 of 4 tasks

Generating Angular component fails with invalid path #18805

austinw-fineart opened this issue Aug 24, 2023 · 5 comments · Fixed by #18933
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@austinw-fineart
Copy link

Current Behavior

Generating Angular component fails with error:

NX The path provided (../../../..) does not exist under the project root (apps/products). Please make sure to provide a path that exists under the project root.

Expected Behavior

Generating Angular components should just work™

GitHub Repo

https://github.com/nrwl/nx-examples

Steps to Reproduce

  1. npx create-nx-workspace@latest
√ Where would you like to create your workspace? · org
√ Which stack do you want to use? · angular
√ Integrated monorepo, or standalone project? · integrated
√ Application name · org
√ Default stylesheet format · scss
√ Test runner to use for end to end (E2E) tests · cypress
√ Would you like to use Standalone Components in your application? · No
√ Would you like to add routing? · Yes
√ Enable distributed caching to make your CI faster · No
  1. Try generating component
PS C:\Users\Austin\org\apps\org\src\app> npx nx g component
√ Which generator would you like to use? · @nx/angular:component

>  NX  Generating @nx/angular:component

√ What name would you like to use for the component? · test

 >  NX   The path provided (../../../..) does not exist under the project root (apps/org). Please make sure to provide a path that exists under the project root.

Nx Report

Node   : 18.17.1
   OS     : win32-x64
   npm    : 9.8.1

   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/angular        : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/web            : 16.7.4
   @nx/webpack        : 16.7.4
   typescript         : 5.1.6

Failure Logs

>  NX   The path provided (../../../..) does not exist under the project root (apps/org). Please make sure to provide a path that exists under the project root.


Error: The path provided (../../../..) does not exist under the project root (apps/org). Please make sure to provide a path that exists under the project root.
    at validatePathIsUnderProjectRoot (C:\Users\Austin\org\node_modules\@nx\angular\src\generators\utils\validations.js:36:15)
    at validateOptions (C:\Users\Austin\org\node_modules\@nx\angular\src\generators\component\lib\validate-options.js:7:54)
    at C:\Users\Austin\org\node_modules\@nx\angular\src\generators\component\component.js:10:35
    at Generator.next (<anonymous>)
    at C:\Users\Austin\org\node_modules\tslib\tslib.js:169:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\Users\Austin\org\node_modules\tslib\tslib.js:165:16)
    at componentGenerator (C:\Users\Austin\org\node_modules\@nx\angular\src\generators\component\component.js:9:20)
    at Object.<anonymous> (C:\Users\Austin\org\node_modules\nx\src\command-line\generate\generate.js:251:36)
    at Generator.next (<anonymous>)

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Last known good version: 16.6.0

@stanft
Copy link

stanft commented Aug 24, 2023

The problem also occurs on macOS. A workaround is to set the path to the component's base directory via --path.

@FrozenPandaz FrozenPandaz added scope: angular Issues related to Angular support in Nx blocked: repro needed labels Aug 24, 2023
@FrozenPandaz
Copy link
Collaborator

I'm not able to reproduce this on https://github.com/nrwl/nx-examples or on a new angular workspace. Could you please provide an exact repo/branch where you can see this issue?

@austinw-fineart
Copy link
Author

Sure here's a repo where I can reproduce it: https://github.com/austinw-fineart/org

@emmettito
Copy link

I am also experiencing this issue. My terminal output is below. I have verified that the problem exists on macOS Ventura AND Windows 11.

emmett:~/Desktop$ npx create-nx-workspace
Need to install the following packages:
[email protected]
Ok to proceed? (y) y

NX Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · temp
✔ Which stack do you want to use? · angular
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · website
✔ Default stylesheet format · scss
✔ Test runner to use for end to end (E2E) tests · playwright
✔ Would you like to use Standalone Components in your application? · Yes
✔ Would you like to add routing? · Yes
✔ Enable distributed caching to make your CI faster · No

NX Creating your v16.7.4 workspace.

To make sure the command works reliably in all environments, and that the preset is applied correctly,
Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✔ Successfully created the workspace: temp.

emmett:/Desktop$ cd temp/apps/website/src/app/
emmett:
/Desktop/temp/apps/website/src/app$ npx nx g c new-component --verbose
✔ Which generator would you like to use? · @nx/angular:component

NX Generating @nx/angular:component

NX The path provided (../../../..) does not exist under the project root (apps/website). Please make sure to provide a path that exists under the project root.

Error: The path provided (../../../..) does not exist under the project root (apps/website). Please make sure to provide a path that exists under the project root.
at validatePathIsUnderProjectRoot (/Users/emmett/Desktop/temp/node_modules/@nx/angular/src/generators/utils/validations.js:36:15)
at validateOptions (/Users/emmett/Desktop/temp/node_modules/@nx/angular/src/generators/component/lib/validate-options.js:7:54)
at /Users/emmett/Desktop/temp/node_modules/@nx/angular/src/generators/component/component.js:10:35
at Generator.next ()
at /Users/emmett/Desktop/temp/node_modules/tslib/tslib.js:169:75
at new Promise ()
at Object.__awaiter (/Users/emmett/Desktop/temp/node_modules/tslib/tslib.js:165:16)
at componentGenerator (/Users/emmett/Desktop/temp/node_modules/@nx/angular/src/generators/component/component.js:9:20)
at Object. (/Users/emmett/Desktop/temp/node_modules/nx/src/command-line/generate/generate.js:251:36)
at Generator.next ()

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

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 Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants