LoginSignup
6
1

More than 5 years have passed since last update.

Angular Multiple Projects で Default app project を消したら Storybook が動かなくなった話

Posted at

(ニッチな) 前提

  • Angular CLI の Multiple Projects でアプリケーションを実装している
  • $ ng new xxx で最初に作られる Default app project を使っていない
  • Storybook を使っている
  • Default app project を削除している

エラー

yarn run v1.13.0
$ build-storybook
info @storybook/angular v4.1.11
info
info clean outputDir..
info => Copying prebuild dll's..
info => Building manager..
info => Loading manager config..
info => Loading presets
info => Loading custom addons config.
info => Compiling manager..
info => manager built (9.06 s)
WARN asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
WARN This can impact web performance.
WARN Assets:
WARN   vendors~main.eee3f7dae582b03c6e6f.bundle.js (885 KiB)
WARN entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
WARN Entrypoints:
WARN   main (887 KiB)
WARN       runtime~main.3aaa912fd37e258bb4b5.bundle.js
WARN       vendors~main.eee3f7dae582b03c6e6f.bundle.js
WARN       main.23787938b278f416c096.bundle.js
WARN
WARN webpack performance recommendations:
WARN You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
WARN For more info visit https://webpack.js.org/guides/code-splitting/
info => Building preview..
info => Loading preview config..
info => Loading presets
info => Using default options for ForkTsCheckerWebpackPlugin
(node:6578) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'architect' of undefined
    at getAngularCliWebpackConfigOptions (/Users/wataru.kasahara/work/triangle/node_modules/@storybook/angular/dist/server/angular-cli_config.js:76:15)
    at Object.webpackFinal (/Users/wataru.kasahara/work/triangle/node_modules/@storybook/angular/dist/server/framework-preset-angular-cli.js:14:92)
    at accumulationPromise.then.newConfig (/Users/wataru.kasahara/work/triangle/node_modules/@storybook/angular/node_modules/@storybook/core/dist/server/presets.js:78:72)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:6578) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:6578) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 21.41s.

デバッグ

  • エラーにある node_modules/@storybook/angular/dist/server/angular-cli_config.js:76:15 を確認
    • エラーに表示されているコードはビルドされているものなので少し行数は異なるが angular-cli_config.js と同様
  • architect が無いと言われているので 直前 で project の中身を確認すると undefined
  • 次は ここ で project を決定する projectsdefaultProject を確認すると angular.json をパースしているものだと判明
  • 更に defaultProject は削除済みの Default app project の名前であることから angular.json 内に defaultProject の要素が残っていることが原因と特定

対応

  • angular.json から defaultProject を削除して無事ビルドが通ることを確認
6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1