The current directory isn't part of an Nx workspace

See original GitHub issue

Current Behavior

Whenever I attempt to use the Nx Console to inject an Angular app into the repo, every dry-run returns with an error that reads:

The current directory isn't part of an Nx workspace.

This isn’t the case at all, as I checked over ten times to make sure I was in the right directory. I even went as far as to see if there was something up with my integrated terminal – found nothing of the sort.

Expected Behavior

I expect it to generate an Angular app within the NRWL repo as it should. Nothing complicated.

Steps to Reproduce

  1. Have VS Code with the Nx Console extension installed and running on it.
  2. While in a terminal of your choosing, use the command npx create-nx-workspace <project_name> to create the workspace. (I use Yarn, but this happens to me using NPM as the package manager as well.)
  3. Open the repo using VSCode.
  4. While in the terminal – doesn’t matter if it’s VSCode’s integrated terminal or an external instance – and while in the project’s root directory, enter the following command, punctuated with Enter:
npm i --save-dev @nrwl/angular

OR

yarn add -D @nrwl/angular

(I always did the latter, just FYI.)

Failure Logs

While filling out the form in the console, it executes dry-runs, which always prints out these errors (and it prints out the same one if I attempt to actually execute the widget, anyway).

(I censored out two directory names, but they have no bearing on the bug.)

>  NX  The current directory isn't part of an Nx workspace.

  To create a workspace run:
  npx create-nx-workspace@latest <workspace name>


>  NX   NOTE  For more information please visit https://nx.dev/

The terminal process "/usr/bin/bash '-l', '-c', '/home/<profile_name>/projects/challenges/<project_name>/node_modules/.bin/nx generate @nrwl/angular:application --name=test --no-interactive --dry-run', 'nx generate @nrwl/angular:application --name=test --no-interactive --dry-run'" failed to launch (exit code: 1).

My Discovery

The problem seems to be a result of the dir argument passed into findWorkspaceRoot() in the @nrwl/cli dependency, which is process.cwd(). It’s passing the root directory of my filesystem ( / ) instead of the root directory of my project.

Environment

Not a part of the printed report, but I’m working from a WSL2 environment, and I install Node via NVM.

Node : 15.14.0
  OS   : linux x64
  yarn : 1.22.10
  
  nx : Not Found
  @nrwl/angular : 12.1.1
  @nrwl/cli : 12.1.1
  @nrwl/cypress : 12.1.1
  @nrwl/devkit : 12.1.1
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 12.1.1
  @nrwl/linter : 12.1.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : 8.12.11
  @nrwl/tao : 12.1.1
  @nrwl/web : Not Found
  @nrwl/workspace : 12.1.1
  @nrwl/storybook : Not Found
  @nrwl/gatsby : Not Found
  typescript : 4.1.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
prodktcommented, Apr 16, 2022

This is happening to us now as well. Do you need all our people to submit bug reports or is this prioritized and a temp fix offered?

1reaction
fernandobracarotocommented, Nov 20, 2022

Just got this same message today. Created a new workspace on windows then got the repo on a mac, installed everything then got the message: The current directory isn’t part of an Nx workspace.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"create-nx-workspace" command not found (linxus and ...
On windows I know that this usually means (not recognized cmdlet) that the PATH to executable is not defined but I have no...
Read more >
Hi All I m working on a… - @Nrwl/Community
NX The current directory isn't part of an Nx workspace. To create a workspace run: npx create-nx-workspace@latest <workspace name>.
Read more >
create-nx-workspace
Start using create-nx-workspace in your project by running `npm i create-nx-workspace`. There are 2 other projects in the npm registry using ...
Read more >
Using Nx Workspace generators to scaffold new blog posts
As you can see, Nx generators not only scaffold files but are able to generate entire folder structures, register new Nx libraries or...
Read more >
2 - Creating an Nx Workspace - Angular and NgRx - GitBook
1. Create a new Nx workspace in your workshop folder ... Run the below command in a terminal to make a new nx...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found