Skip to content

Nuxt build error with nuxt-security and nuxt-meilisearch after Nuxt versions >3.14.0 #30511

@njoswald

Description

@njoswald

Environment


  • Operating System: Windows_NT
  • Node Version: v20.16.0
  • Nuxt Version: 3.15.1
  • CLI Version: 3.19.1
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, experimental, meilisearch, compatibilityDate
  • Runtime Modules: [email protected], [email protected]
  • Build Modules: -

Reproduction

https://github.com/njoswald/nuxt-module-compatability-meilisearch

Describe the bug

I am running into a build error when I have both Nuxt security and Nuxt Meilisearch modules active at the same time. They had been working together well previously on my app until Nuxt v3.14.0 released. Now, the only workaround I can find is to either disable nuxt security or to turn off server side usage with the meilisearch module. So, I have been unable to upgrade Nuxt in my project from v3.13.2.

The following is the error:

[worker reload] [worker init] {repoPath}/.nuxt/dev/index.mjs failed


[cause]: Cannot access '_sharedRuntimeConfig' before initialization

    at useRuntimeConfig (node_modules\nitropack\dist\runtime\internal\config.mjs:15:5)
    at <anonymous> (node_modules\nuxt-meilisearch\dist\runtime\server\utils\meilisearch.mjs:3:63)
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Unfortunately, I need both the server side usage and nuxt security for my app, so I have run into a roadblock. I am submitting to the Nuxt issues since it is the error is sourcing from these two modules only when they are enabled together. There are no errors when they are enabled separately.

I did read through #29882 and #29943, but the discussions were not assisting me with this issue. Along with that, the error was not resolved after the most recent Nuxt version (3.15.1).

Sorry if this is not Nuxt related, but I could not find the source of the issue. Please let me know if it appears to be an issue of one of the modules, and I will submit there instead.

Additional context

In the repo, run npm install and npm run dev to see the error. Comment out either nuxt-security or the 'serverSideUsage' line of the meilisearch config to make the error go away.

Nuxt config:

// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from "nuxt/config"

export default defineNuxtConfig({
  modules: [
      // Comment out 'nuxt-security' or the 'serverSideUsage' line to make error go away.
      'nuxt-security',
      'nuxt-meilisearch',
  ],

  experimental: { appManifest: false },

  meilisearch: {
      hostUrl: 'https://edge.meilisearch.com',

      // Comment out 'nuxt-security' or the 'serverSideUsage' line to make error go away.
      serverSideUsage: true
  },

  compatibilityDate: '2025-01-08',
})

package.json:

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "start": "node .output/server/index.mjs",
    "test": "vitest",
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  },
  "devDependencies": {
    "nuxt": "^3.15.1",
    "nuxt-meilisearch": "^1.3.10"
  },
  "dependencies": {
    "nuxt-security": "^2.1.5",
    "vue-router": "latest"
  },
  "overrides": {
    "vue": "latest"
  },
  "engines": {
    "node": "20.x"
  }
}

Logs

[worker reload] [worker init] {repoPath}/.nuxt/dev/index.mjs failed



  [cause]: Cannot access '_sharedRuntimeConfig' before initialization

      at useRuntimeConfig (node_modules\nitropack\dist\runtime\internal\config.mjs:15:5)
      at <anonymous> (node_modules\nuxt-meilisearch\dist\runtime\server\utils\meilisearch.mjs:3:63)
      at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
      at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
      at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions