Skip to content

TypeError: Cannot add property _layers, object is not extensible #205

@ineshbose

Description

@ineshbose

Environment


  • Operating System: Linux
  • Node Version: v20.17.0
  • Package Manager: pnpm@9.11.0

Reproduction

https://stackblitz.com/github/nuxt-modules/tailwindcss/tree/c12-refactor

Run pnpm test basic

Describe the bug

Getting an error: TypeError: Cannot add property _layers, object is not extensible

This is when the config is equal to [Module: null prototype] { } and I have passed a custom merger as well that is based of defu (also creates copy of objects using klona). I'm not 100% sure where the issue may be lying in this case.

Additional context

In the test fixture, I am trying to load tailwind.config.js that uses CommonJS syntax but it loadConfig / jiti doesn't seem to be picking that 🤔

It'll work if the extension is .cjs or the file uses ESM, but not all users may have that scenario.

Logs

TypeError: Cannot add property _layers, object is not extensible
 ❯ extendConfig node_modules/.pnpm/c12@2.0.1_magicast@0.3.5/node_modules/c12/dist/shared/c12.CLRr5qYj.cjs:237:18
 ❯ loadConfig node_modules/.pnpm/c12@2.0.1_magicast@0.3.5/node_modules/c12/dist/shared/c12.CLRr5qYj.cjs:205:11
 ❯ Object.loadConfigs src/internal-context/load.ts:119:27
 ❯ src/module.ts:93:23
 ❯ initNuxt node_modules/.pnpm/nuxt@3.13.2_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.11.0_encoding@0.1.1_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4510:3
 ❯ loadNuxt node_modules/.pnpm/nuxt@3.13.2_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.11.0_encoding@0.1.1_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4673:5
 ❯ Module.loadNuxt node_modules/.pnpm/@nuxt+kit@3.13.2_magicast@0.3.5_rollup@4.18.0_webpack-sources@3.2.3/node_modules/@nuxt/kit/dist/index.mjs:2664:19
 ❯ loadFixture node_modules/.pnpm/@nuxt+test-utils@3.14.2_h3@1.13.0_happy-dom@15.7.4_magicast@0.3.5_nitropack@2.9.7_@openteleme_3tgsw6odecy35hpfofogcjtniu/node_modules/@nuxt/test-utils/dist/shared/test-utils.CaqvQLs_.mjs:103:16
    101|     });
    102|     const buildDir = ctx.nuxt.options.buildDir;
    103|     if (!existsSync(buildDir)) {
       |                ^
    104|       await promises.mkdir(buildDir, { recursive: true });
    105|       ctx.teardown = ctx.teardown || [];
 ❯ setup2 node_modules/.pnpm/@nuxt+test-utils@3.14.2_h3@1.13.0_happy-dom@15.7.4_magicast@0.3.5_nitropack@2.9.7_@openteleme_3tgsw6odecy35hpfofogcjtniu/node_modules/@nuxt/test-utils/dist/shared/test-utils.CaqvQLs_.mjs:180:7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions