Skip to content

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

@ineshbose

Description

@ineshbose

Environment



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/[email protected][email protected]/node_modules/c12/dist/shared/c12.CLRr5qYj.cjs:237:18
 ❯ loadConfig node_modules/.pnpm/[email protected][email protected]/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/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4510:3
 ❯ loadNuxt node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_p5ecgqo4fgnxalrrwhgsvb34r4/node_modules/nuxt/dist/index.mjs:4673:5
 ❯ Module.loadNuxt node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@nuxt/kit/dist/index.mjs:2664:19
 ❯ loadFixture node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected]_@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/@[email protected][email protected][email protected][email protected][email protected]_@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