Closed christianacca closed 2 years ago
try upgrading storybook to rc version
npx sb upgrade --prerelease
I can confirm the issue. Struggling with the same.
npx sb upgrade --prerelease
fixed the initial error but unfortunately another error occurred.
My error looks like this running nx run design-system:storybook
:
> nx run design-system:storybook
info => Loading presets
WARN Failed to load preset: "/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-ivy.js"
ERR! Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@angular/compiler-cli/bundles/ngcc/index.js
ERR! require() of ES modules is not supported.
ERR! require() of /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@angular/compiler-cli/bundles/ngcc/index.js from /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-ivy.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
ERR! Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@angular/compiler-cli/package.json.
ERR!
ERR! at new NodeError (internal/errors.js:322:7)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
ERR! at Module.load (internal/modules/cjs/loader.js:950:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:790:12)
ERR! at Module.require (internal/modules/cjs/loader.js:974:19)
ERR! at require (internal/modules/cjs/helpers.js:93:18)
ERR! at Object.<anonymous> (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-ivy.js:70:14)
ERR! at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR! at Module.load (internal/modules/cjs/loader.js:950:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:790:12)
ERR! at Module.require (internal/modules/cjs/loader.js:974:19)
ERR! at require (internal/modules/cjs/helpers.js:93:18)
ERR! at interopRequireDefault (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/core-common/dist/cjs/presets.js:159:16)
ERR! at getContent (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/core-common/dist/cjs/presets.js:175:10)
ERR! at loadPreset (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/core-common/dist/cjs/presets.js:184:20)
ERR! Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@angular/compiler-cli/bundles/ngcc/index.js
ERR! require() of ES modules is not supported.
ERR! require() of /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@angular/compiler-cli/bundles/ngcc/index.js from /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-ivy.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
ERR! Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@angular/compiler-cli/package.json.
ERR!
ERR! at new NodeError (internal/errors.js:322:7)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
ERR! at Module.load (internal/modules/cjs/loader.js:950:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:790:12)
ERR! at Module.require (internal/modules/cjs/loader.js:974:19)
ERR! at require (internal/modules/cjs/helpers.js:93:18)
ERR! at Object.<anonymous> (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-ivy.js:70:14)
ERR! at Module._compile (internal/modules/cjs/loader.js:1085:14)
ERR! at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
ERR! at Module.load (internal/modules/cjs/loader.js:950:32)
ERR! at Function.Module._load (internal/modules/cjs/loader.js:790:12)
ERR! at Module.require (internal/modules/cjs/loader.js:974:19)
ERR! at require (internal/modules/cjs/helpers.js:93:18)
ERR! at interopRequireDefault (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/core-common/dist/cjs/presets.js:159:16)
ERR! at getContent (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/core-common/dist/cjs/presets.js:175:10)
ERR! at loadPreset (/Users/machetanz/@smarter-ecommerce/ui-foundation/node_modules/@storybook/core-common/dist/cjs/presets.js:184:20) {
ERR! code: 'ERR_REQUIRE_ESM'
ERR! }
info => Loading 1 config file in "/Users/machetanz/@smarter-ecommerce/ui-foundation/libs/design-system/.storybook"
info => Loading 9 other files in "/Users/machetanz/@smarter-ecommerce/ui-foundation/libs/design-system/.storybook"
info => Adding stories defined in "/Users/machetanz/@smarter-ecommerce/ui-foundation/libs/design-system/.storybook/main.js"
<i> [webpack-dev-middleware] wait until bundle finished
info => Found custom tsconfig.json
info => Using implicit CSS loaders
info => Loading angular-cli config
info => Using angular project "design-system-demo:build" for configuring Storybook
ERR! => Could not get angular cli webpack config
TypeError: Cannot read property 'target' of undefined
We're having the same issue. However, mine wasn't fixed by rolling back to a version previous to 13.2.x. even 13.0.x or 13.1.x didn't help. We traced the error back to a Pull Request in which we primarily upgrade Angular from 12 to 13.
Last Friday I tried npx sb upgrade --prerelease
. As @LukasMachetanz described, it fixed the intial error but instead now complains about a new error. It seems that it can't resolve packages described in the compilerOptions.paths
property of the tsconfig.json
.
Today (or on the weekend) the new nx and Storybook versions got released which results in the same behavior.
Apparently there is an existing issue on that: https://github.com/storybookjs/storybook/issues/16759 The workaround from that issue seems to be working for us.
@christianacca In your repo it looks like you're still on @storybook/*
v6.3.0. In order to be compatible with Angular 13 you need to use Storybook v6.4.0. In general when upgrading, the best is to use nx migrate as we'll make sure to upgrade you to the correct Angular and Storybook versions. //cc @LukasMachetanz I think same in your case.
@simonknittel I think your error is a different one and not related to the ESM modules not being found. It looks like the tsconfig inheritance chain is not properly resolved in the latest Storybook 6.4. It's on the Storybook side, but I'll try to look into how to fix this.
I am not sure which storybook version I had when I posted https://github.com/nrwl/nx/issues/7823#issuecomment-979845513, but I am using v6.4.0 now.
Currently I am also struggling with resolvement issues as described by @simonknittel in https://github.com/nrwl/nx/issues/7823#issuecomment-981385599. I am pretty sure we have the same issue here.
@juristr Thanks for looking into this.
@juristr she I can try that upgrade. Hopefully the next version of nx (I was using 13.2.1) will default to using Storybook 6.4 as the dependency...
@christianacca Yep it will. Work is already underway => https://github.com/nrwl/nx/pull/7917
PR merged, so closing this! :)
Thanks for tackling this. Everything works as expected now.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Receive an error trying to run storybook for an angular library in a newly minted nx 13.2 angular workspace.
Expected Behavior
Should be able to run storybook successfully
Steps to Reproduce
To see the problem:
The above repo was created using the following commands:
NOTE: I was able to reproduce the problem with both publishable and non-publishable/buildable library
Failure Logs
Environment