feat(core): add error when root project would be '.' (#16999)

This commit is contained in:
Craigory Coppola 2023-05-12 18:27:26 -04:00 committed by GitHub
parent 95421c6945
commit 024193fb5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}/`;