LoginSignup
0
0

More than 3 years have passed since last update.

[Vueサーバサイドレンダリング] webpackでoutput.libraryTarget should be commonjs2 と怒られた話[Vue SSR]

Posted at

Vue SSR 公式ガイドに沿って実装したら怒られた

公式ドキュメントを参考にして、Vue SSR を実装しようとしたところ、
webpackを経由してサーバーバンドルを作ろうとしたら、タイトルの通り怒られた。
vue-ssr-server-bundle.json が出来上がらない。。。

[公式ドキュメント]
https://ssr.vuejs.org/ja/guide/

[バグ]

[vue-server-renderer-webpack-plugin] webpack config `output.libraryTarget` should be "commonjs2".

[webpack-cli] Uncaught exception: Error: Entry "app" not found. Did you specify the correct entry option?
[webpack-cli] Error: Entry "app" not found. Did you specify the correct entry option?
    at /Users/s04693/Documents/sandbox/micres-vss/node_modules/vue-server-renderer/server-plugin.js:76:13
    at Hook.eval [as callAsync] (eval at create (/Users/s04693/Documents/sandbox/micres-vss/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/s04693/Documents/sandbox/micres-vss/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.emitAssets (/Users/s04693/Documents/sandbox/micres-vss/node_modules/webpack/lib/Compiler.js:763:19)
    at /Users/s04693/Documents/sandbox/micres-vss/node_modules/webpack/lib/Compiler.js:412:10
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

ちゃんと、commonjs2 にもしてるし、 entry も正しい。。。なぜ?

解決方法

Webpackのバージョンが4から5に上がったのが理由だった。Issueにもなっている。

なのでバージョンを下げれば無事 webpack でバンドルが作られる。めでたしめでたし。

npm install --save-dev webpack@4 webpack-cli@3

早く治らないかなー。

0
0
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
0
0