diff --git a/packages/nx/src/config/workspaces.ts b/packages/nx/src/config/workspaces.ts index 0ba9c4f2a7767..804ea4028c33e 100644 --- a/packages/nx/src/config/workspaces.ts +++ b/packages/nx/src/config/workspaces.ts @@ -762,6 +762,13 @@ function buildProjectConfigurationFromPackageJson( ): ProjectConfiguration & { name: string } { const normalizedPath = path.split('\\').join('/'); const directory = dirname(normalizedPath); + + if (!packageJson.name && directory === '.') { + throw new Error( + 'Nx requires the root package.json to specify a name if it is being used as an Nx project.' + ); + } + let name = packageJson.name ?? toProjectName(normalizedPath); if (nxJson?.npmScope) { const npmPrefix = `@${nxJson.npmScope}/`;