Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9082

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

$
0
0

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にもなっている。

https://github.com/vuejs/vue/issues/11718

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

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

早く治らないかなー。


Viewing all articles
Browse latest Browse all 9082

Latest Images

Trending Articles