Skip to content

Nuxt upgrade from 3.17.5 to 3.17.6 causing 500 "Cannot redefine property: default" with ioredis #32715

@wtagain

Description

@wtagain

Environment

  • Operating System: Linux
  • Node Version: v20.19.1
  • Nuxt Version: 3.17.6
  • CLI Version: 3.26.3
  • Nitro Version: 2.12.3
  • Package Manager: pnpm@8.15.6
  • Builder: -
  • User Config: compatibilityDate, devtools
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-5n9zguhs

Describe the bug

Import ioredis in plugins, import ioredis in server middleware and new one, then it will cause this 500 error.
This operation seems like to add ioredis into the nuxt.config.ts build transpile.

Additional context

No response

Logs

ℹ Error: Cannot redefine property: default

 ⁃ at eval (node_modules/.pnpm/ioredis@5.6.1/node_modules/ioredis/built/index.js:6:8)
 ⁃ at ViteNodeRunner.runModule (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:414:10)
 ⁃ at ViteNodeRunner.directRequest (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:392:14)
 ⁃ at async ViteNodeRunner.cachedRequest (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:206:11)
 ⁃ at async ViteNodeRunner.dependencyRequest (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:256:10)
 ⁃ at async eval (plugins/redis.server.ts:2:31)

   1 ┃  import IORedis from 'ioredis';
 ❯ 2 ┃  
   3 ┃  export default defineNuxtPlugin(() => {});
   4 ┃  

 ⁃ at async ViteNodeRunner.runModule (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:414:4)
 ⁃ at async ViteNodeRunner.directRequest (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:392:3)
 ⁃ at async ViteNodeRunner.cachedRequest (node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:206:11)

[CAUSE]
TypeError {
  stack: 'Cannot redefine property: default\n' +
  'at eval (./node_modules/.pnpm/ioredis@5.6.1/node_modules/ioredis/built/index.js:6:8)\n' +
  'at ViteNodeRunner.runModule (./node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:414:10)\n' +
  'at ViteNodeRunner.directRequest (./node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:392:14)\n' +
  'at async ViteNodeRunner.cachedRequest (./node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:206:11)\n' +
  'at async ViteNodeRunner.dependencyRequest (./node_modules/.pnpm/vite-node@3.2.4_jiti@2.4.2/node_modules/vite-node/dist/client.mjs:256:10)\n' +
  'at async eval (./plugins/redis.server.ts:2:31)\n' +
  'at async ViteNodeRunner.runModule (./node_modules/.pnpm/vite-node'... 400 more characters,
  message: 'Cannot redefine property: default',
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions