The current directory isn't part of an Nx workspace
See original GitHub issueCurrent 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
- Have VS Code with the Nx Console extension installed and running on it.
- 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.) - Open the repo using VSCode.
- 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:
- Created 2 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top Related StackOverflow Question
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?
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.