LoginSignup
5
2

More than 3 years have passed since last update.

Nuxt 2.8.0 で nuxt generate に失敗する

Posted at

前提

Gitlab PagesにNuxt.jsで生成した静的ページをホスティングしているのですが、
Nuxt.jsのバージョンを上げたところ、nuxt generate の実行に失敗するようになりました。

環境

  • node.js 10.15.3
  • yarn 1.16.0
  • nuxt.js 2.1.0 -> 2.8.0

現象

% yarn run generate
yarn run v1.16.0
$ nuxt generate
ℹ Preparing project for development
ℹ Initial build may take a while
✔ Builder initialized
✔ Nuxt files generated

✔ Client
  Compiled successfully in 6.76s

✔ Server
  Compiled successfully in 5.56s

ℹ Waiting for file changes

 FATAL  ENOENT: no such file or directory, stat '/home/epaew/workspace/nuxt_app/.nuxt/dist/client'




   ╭─────────────────────────────────────────────────────────────╮
   │                                                             │
   │   ✖ Nuxt Fatal Error                                       │
   │                                                             │
   │   Error: ENOENT: no such file or directory, stat            │
   │   '/home/epaew/workspace/nuxt_app/.nuxt/dist/client'        │
   │                                                             │
   ╰─────────────────────────────────────────────────────────────╯

error Command failed with exit code 1.

解決策

GitHub に issue が上がっていました
https://github.com/nuxt/nuxt.js/issues/5840#issuecomment-497521402

Solution: You are mixing cjs with es syntax for nuxt.config. Simply using export default fixes issue.

nuxt.config.js を以下の通り修正

-module.exports = {
+export default {

古い Nuxt で create-nuxt-app した場合、 nuxt.config.js あたりに CommonJS の記法が残ってしまっているみたいです。

5
2
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
5
2