diff --git a/packages/angular/src/generators/setup-mfe/files/entry-module-files/entry.component.ts__tmpl__ b/packages/angular/src/generators/setup-mfe/files/entry-module-files/entry.component.ts__tmpl__
index 7e4e6ceef621e..05063986ac261 100644
--- a/packages/angular/src/generators/setup-mfe/files/entry-module-files/entry.component.ts__tmpl__
+++ b/packages/angular/src/generators/setup-mfe/files/entry-module-files/entry.component.ts__tmpl__
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
@Component({
- selector: '<%= npmScope %>-<%= appName %>-entry',
+ selector: '<%= appName %>-entry',
template: `
<%= appName %>'s Remote Entry Component
`,
styles: [`
.remote-entry {
@@ -10,4 +10,4 @@ import { Component } from '@angular/core';
padding: 5px;
}`]
})
-export class RemoteEntryComponent {}
\ No newline at end of file
+export class RemoteEntryComponent {}
diff --git a/packages/angular/src/generators/setup-mfe/lib/add-entry-module.ts b/packages/angular/src/generators/setup-mfe/lib/add-entry-module.ts
index a2d2b7dec5291..81f539083480c 100644
--- a/packages/angular/src/generators/setup-mfe/lib/add-entry-module.ts
+++ b/packages/angular/src/generators/setup-mfe/lib/add-entry-module.ts
@@ -12,7 +12,6 @@ export function addEntryModule(
appRoot: string
) {
if (mfeType === 'remote') {
- const { npmScope } = readWorkspaceConfiguration(host);
generateFiles(
host,
joinPathFragments(__dirname, '../files/entry-module-files'),
@@ -20,7 +19,6 @@ export function addEntryModule(
{
tmpl: '',
appName,
- npmScope,
routing,
}
);
diff --git a/packages/nx/src/config/nx-json.ts b/packages/nx/src/config/nx-json.ts
index 0fedd594ca962..591aa93b179d5 100644
--- a/packages/nx/src/config/nx-json.ts
+++ b/packages/nx/src/config/nx-json.ts
@@ -35,7 +35,7 @@ export interface NxJsonConfiguration {
/**
* NPM Scope that the workspace uses
*/
- npmScope: string;
+ npmScope?: string;
/**
* Default options for `nx affected`
*/
diff --git a/packages/nx/src/config/workspaces.ts b/packages/nx/src/config/workspaces.ts
index 4d682fed63e59..67213951b4567 100644
--- a/packages/nx/src/config/workspaces.ts
+++ b/packages/nx/src/config/workspaces.ts
@@ -587,10 +587,12 @@ function buildProjectConfigurationFromPackageJson(
nxJson: NxJsonConfiguration
): ProjectConfiguration & { name: string } {
const directory = dirname(path).split('\\').join('/');
- const npmPrefix = `@${nxJson.npmScope}/`;
let name = packageJson.name ?? toProjectName(directory, nxJson);
- if (name.startsWith(npmPrefix)) {
- name = name.replace(npmPrefix, '');
+ if (nxJson.npmScope) {
+ const npmPrefix = `@${nxJson.npmScope}/`;
+ if (name.startsWith(npmPrefix)) {
+ name = name.replace(npmPrefix, '');
+ }
}
return {
root: directory,
diff --git a/packages/nx/src/hasher/hasher.ts b/packages/nx/src/hasher/hasher.ts
index 00c13b4fb7be9..788e39952afc0 100644
--- a/packages/nx/src/hasher/hasher.ts
+++ b/packages/nx/src/hasher/hasher.ts
@@ -490,7 +490,7 @@ class ProjectHasher {
res.projects ??= {};
return res;
} catch {
- return { npmScope: '' };
+ return {};
}
}
}
diff --git a/packages/nx/src/project-graph/build-dependencies/explicit-package-json-dependencies.ts b/packages/nx/src/project-graph/build-dependencies/explicit-package-json-dependencies.ts
index 3b60a92b22ac5..d833097bad755 100644
--- a/packages/nx/src/project-graph/build-dependencies/explicit-package-json-dependencies.ts
+++ b/packages/nx/src/project-graph/build-dependencies/explicit-package-json-dependencies.ts
@@ -38,7 +38,10 @@ function createPackageNameMap(w: Workspace) {
const packageJson = parseJson(
defaultFileRead(join(w.projects[projectName].root, 'package.json'))
);
- res[packageJson.name || `@${w.npmScope}/${projectName}`] = projectName;
+ res[
+ packageJson.name ??
+ (w.npmScope ? `@${w.npmScope}/${projectName}` : projectName)
+ ] = projectName;
} catch (e) {}
}
return res;
diff --git a/packages/nx/src/project-graph/file-utils.ts b/packages/nx/src/project-graph/file-utils.ts
index 8b169ec91b647..f12207fbdbd0a 100644
--- a/packages/nx/src/project-graph/file-utils.ts
+++ b/packages/nx/src/project-graph/file-utils.ts
@@ -158,9 +158,6 @@ export function readNxJson(
path: string = `${workspaceRoot}/nx.json`
): NxJsonConfiguration {
let config = readJsonFile(path);
- if (!config.npmScope) {
- throw new Error(`nx.json must define the npmScope property.`);
- }
if (config.extends) {
config = {