LoginSignup
1
0

More than 3 years have passed since last update.

Nuxtのマイナーアップデートに手こずった件

Last updated at Posted at 2020-07-21

結論

Nuxtをv2.13系にアップデートするときは.envディレクトリを使わないこと

事の発端

v2.12 → v2.13 にアップデートしようと思うと以下エラーに遭遇する

 FATAL  EISDIR: illegal operation on a directory, read                                                                                                                                                                                                                17:10:04

  at Object.readSync (fs.js:564:3)
  at tryReadSync (fs.js:349:20)
  at Object.readFileSync (fs.js:386:19)
  at loadEnv (node_modules/@nuxt/config/dist/config.js:4622:38)
  at Object.loadNuxtConfig (node_modules/@nuxt/config/dist/config.js:4539:15)
  at loadNuxtConfig (node_modules/@nuxt/cli/dist/cli-index.js:2725:32)
  at NuxtCommand.getNuxtConfig (node_modules/@nuxt/cli/dist/cli-index.js:2848:26)
  at Object._listenDev (node_modules/@nuxt/cli/dist/cli-dev.js:70:30)
  at Object.startDev (node_modules/@nuxt/cli/dist/cli-dev.js:53:25)
  at Object.run (node_modules/@nuxt/cli/dist/cli-dev.js:47:16)


   ╭───────────────────────────────────────────────────────────╮
   │                                                           │
   │   ✖ Nuxt Fatal Error                                      │
   │                                                           │
   │   Error: EISDIR: illegal operation on a directory, read   │
   │                                                           │
   ╰───────────────────────────────────────────────────────────╯

原因

v2.13で.envがサポートされた

Built-in .env support and runtimeConfig
https://ja.nuxtjs.org/guide/release-notes/#v2.13.0

たまたまうちのプロダクトで.envディレクトリ配下に各環境ごとのenvファイルを作ってたのが原因だった

node_modules/@nuxt/config/dist/config.js
  // Load env
  envConfig = {
    dotenv: '.env',
    env: process.env,
    expand: true,
    ...envConfig
  };
  const env = loadEnv(envConfig, rootDir);

nuxt側ではファイル見にいくつもりなのに、同じ名前のディレクトリがあればそれはError: EISDIR: illegal operation on a directory, readにもなりますよねぇ・・・

教訓

めんどくさくても、エラーわからなかったら中の実装(node-modules配下の)見に行こう

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