File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,7 +66,10 @@ import { output } from '../../utils/output';
6666import { existsSync , writeFileSync } from 'fs' ;
6767import { workspaceRoot } from '../../utils/workspace-root' ;
6868import { isCI } from '../../utils/is-ci' ;
69- import { getNxRequirePaths } from '../../utils/installation-directory' ;
69+ import {
70+ getNxInstallationPath ,
71+ getNxRequirePaths ,
72+ } from '../../utils/installation-directory' ;
7073import { readNxJson } from '../../config/configuration' ;
7174import { runNxSync } from '../../utils/child-process' ;
7275import { daemonClient } from '../../daemon/client/client' ;
@@ -1849,8 +1852,10 @@ export function nxCliPath(nxWorkspaceRoot?: string) {
18491852 } ,
18501853 license : 'MIT' ,
18511854 } ) ;
1855+ const root = nxWorkspaceRoot ?? workspaceRoot ;
1856+ const isNonJs = ! existsSync ( join ( root , 'package.json' ) ) ;
18521857 copyPackageManagerConfigurationFiles (
1853- nxWorkspaceRoot ?? workspaceRoot ,
1858+ isNonJs ? getNxInstallationPath ( root ) : root ,
18541859 tmpDir
18551860 ) ;
18561861
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
2323 readYamlFile ,
2424 writeJsonFile ,
2525} from './fileutils' ;
26+ import { getNxInstallationPath } from './installation-directory' ;
2627import { PackageJson , readModulePackageJson } from './package-json' ;
2728import { workspaceRoot } from './workspace-root' ;
2829
@@ -296,6 +297,10 @@ export function findFileInPackageJsonDirectory(
296297 directory : string = process . cwd ( )
297298) : string | null {
298299 while ( ! existsSync ( join ( directory , 'package.json' ) ) ) {
300+ if ( directory === workspaceRoot ) {
301+ // we reached the workspace root and we didn't find a package.json file
302+ return null ;
303+ }
299304 directory = dirname ( directory ) ;
300305 }
301306 const path = join ( directory , file ) ;
@@ -406,7 +411,11 @@ export function createTempNpmDirectory() {
406411
407412 // A package.json is needed for pnpm pack and for .npmrc to resolve
408413 writeJsonFile ( `${ dir } /package.json` , { } ) ;
409- copyPackageManagerConfigurationFiles ( workspaceRoot , dir ) ;
414+ const isNonJs = ! existsSync ( join ( workspaceRoot , 'package.json' ) ) ;
415+ copyPackageManagerConfigurationFiles (
416+ isNonJs ? getNxInstallationPath ( workspaceRoot ) : workspaceRoot ,
417+ dir
418+ ) ;
410419
411420 const cleanup = async ( ) => {
412421 try {
You can’t perform that action at this time.
0 commit comments