metarhia/impress

Cannot set property x of #<Object> which has only a getter

DmitryScaletta opened this issue · 0 comments

Impress and Node.js versions

impress: 3.0.13, node: v21.1.0

Platform

No response

Describe the bug

drizzle-orm@0.29.0

First the module loader loads the main package which imports a relations module which exports a relations function.

node_modules/drizzle-orm/index.cjs

https://github.com/drizzle-team/drizzle-orm/blob/0d833d1ca78735e29b124e2a672bda2c85738f48/drizzle-orm/src/index.ts#L10

image

node_modules/drizzle-orm/relations.cjs

https://github.com/drizzle-team/drizzle-orm/blob/0d833d1ca78735e29b124e2a672bda2c85738f48/drizzle-orm/src/relations.ts#L495

image

Then it tries to load a relations submodule (the same name as the function that was already loaded).

node_modules/drizzle-orm/package.json

image

So lib[subName] is already exists and it points to the same object as sub.relations.

I added this debug code here:

impress/lib/deps.js

Lines 57 to 58 in 4cabe81

const sub = appRequire(name + '/' + subName);
lib[subName] = sub;

const sub = appRequire(name + '/' + subName);
if (name === 'drizzle-orm' && subName === 'relations') {
  console.log(lib[subName] && (lib[subName] === sub[subName])); // true
}
lib[subName] = sub; // the error is here
TypeError: Cannot set property relations of #<Object> which has only a getter
    at loadModule (node_modules\impress\lib\deps.js:63:24)
    at Object.<anonymous> (node_modules\impress\lib\deps.js:89:13)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (node_modules\impress\lib\planner.js:3:32)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)

sql submodule is also have this problem.

To Reproduce

  1. Run npm i drizzle-orm@0.29.0
  2. Run npm start
  3. See a module loading error

Expected behavior

No response

Screenshots

No response

Additional context

All drizzle-orm's transpiled code can be found here: https://www.npmjs.com/package/drizzle-orm?activeTab=code