From 55aba1365dabefa9c8c9e5d7856b8c6c1efe47b7 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Mon, 16 Jan 2023 18:19:29 +0200 Subject: [PATCH] fix(storybook): better error handling (#14396) --- packages/storybook/src/executors/utils.ts | 29 ++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/storybook/src/executors/utils.ts b/packages/storybook/src/executors/utils.ts index 45a84130827f7..ba0d30f2f501e 100644 --- a/packages/storybook/src/executors/utils.ts +++ b/packages/storybook/src/executors/utils.ts @@ -34,12 +34,29 @@ export function getStorybookFrameworkPath(uiFramework: UiFramework) { // TODO(katerina): Remove when Storybook 7 function isStorybookV62onwards(uiFramework: string) { - const storybookPackageVersion = require(join( - uiFramework, - 'package.json' - )).version; - - return gte(storybookPackageVersion, '6.2.0-rc.4'); + try { + const storybookPackageVersion = require(join( + uiFramework, + 'package.json' + )).version; + return gte(storybookPackageVersion, '6.2.0-rc.4'); + } catch (e) { + try { + const storybookPackageVersion = require(join( + '@storybook/core-server', + 'package.json' + )).version; + return gte(storybookPackageVersion, '6.2.0-rc.4'); + } catch (e) { + throw new Error( + `Error: ${e} + + It looks like you don\'t have Storybook installed. + Please run the @nrwl/storybook:configuration generator, + or run "npm/yarn" again to install your dependencies.` + ); + } + } } // TODO(katerina): Remove when Storybook 7