diff --git a/packages/nx/src/migrations/update-17-0-0/rm-default-collection-npm-scope.ts b/packages/nx/src/migrations/update-17-0-0/rm-default-collection-npm-scope.ts index 940ada93aab4f..b4dbfe8a8c628 100644 --- a/packages/nx/src/migrations/update-17-0-0/rm-default-collection-npm-scope.ts +++ b/packages/nx/src/migrations/update-17-0-0/rm-default-collection-npm-scope.ts @@ -15,7 +15,7 @@ export default async function update(tree: Tree) { delete nxJson.cli?.['defaultCollection']; - if (Object.keys(nxJson.cli).length < 1) { + if (nxJson?.cli && Object.keys(nxJson.cli).length < 1) { delete nxJson.cli; }