diff --git a/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts b/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts index dcfa74d631..e2b1a41a98 100644 --- a/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts +++ b/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts @@ -23,7 +23,12 @@ export function updateTsconfig(schema: Schema) { const tsConfigPath = 'tsconfig.json'; if (tree.exists(tsConfigPath)) { - let contents = JSON.parse(tree.read(tsConfigPath).toString('utf-8')); + let contents = tree.read(tsConfigPath).toString('utf-8'); + try { + contents = JSON.parse(contents); + } catch (e) { + throw new Error(`Cannot parse ${tsConfigPath}: ${e.message}`); + } delete contents.compilerOptions.paths[ `@${nxJson.npmScope}/${project.root.substr(5)}` ];