Skip to content

Commit 840f5f4

Browse files
authored
fix(core): ensure that global nx works with dot-nx workspace after init (#31249)
This PR fixes an issue with the global `nx` command, where running `nx init` in a non-JS folder (i.e. using dot-nx setup) results in a workspace that doesn't work with the global command. e.g. ``` brew install nx cd some-java-project nx init nx report ``` https://www.loom.com/share/e8dbb2fb7a084300a4dd1e5dff2c0db1 ## Current Behavior `nx report` or any other command fails ## Expected Behavior `nx` commands should work ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent fcd630d commit 840f5f4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/nx/src/command-line/init/implementation/dot-nx/add-nx-scripts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export function generateDotNxSetup(version?: string) {
6363
const changes = host.listChanges();
6464
printChanges(changes);
6565
flushChanges(host.root, changes);
66+
// Ensure that the dot-nx installation is available.
67+
// This is needed when using a global nx with dot-nx, otherwise running any nx command using global command will fail due to missing modules.
68+
execSync('./nx --version', { stdio: 'ignore' });
6669
}
6770

6871
export function normalizeVersionForNxJson(pkg: string, version: string) {

0 commit comments

Comments
 (0)