gurvancampion / nuxt-electron-trpc-prisma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error [ERR_REQUIRE_ESM]: require() of ES Module

NegativeIQ opened this issue · comments

Trying to import node-7z-archive always give Error [ERR_REQUIRE_ESM]: require() of ES Module error.
I tried require, i tried adding "type": "module", nothign works for me.

Maybe im doing something wrong, but since i have fs and path imports that are working fine i dont see problem...
Also tried asking around discord and few people told me it should work just fine.

EDIT:

I ended up using const { default: zip } = await import('node-7z-archive'); inside a function right before i needed to list files in archive. I dont like these solution, but at least it works for now, until actual problem and fix is found.

commented

@NegativeIQ Where do you import the package in your code?

server-> trpc-> routers -> item.ts (created it, its essentially the same as post.ts that is given as example)

commented

I think it's due to the current version of nuxt-electron on this repo. Could you try to upgrade to 0.3.0 or above as it's using vite-electron- plugin and not notbundle anymore to bundle the code inside electron and server folders.
When I have sometime I will update this repo to add support for migrations and update to the latest nuxt-electron version

  "dependencies": {
    "@prisma/client": "4.7.1",
    "@trpc/client": "^10.4.3",
    "@trpc/server": "^10.4.3",
    "node-7z-archive": "^1.1.4",
    "vite-electron-plugin": "^0.8.2",
    "vuetify": "^3.0.6",
    "zod": "^3.19.1"
  },
  "devDependencies": {
    "@antfu/eslint-config": "^0.33.1",
    "electron": "^22.0.0",
    "electron-builder": "^23.6.0",
    "eslint": "^8.29.0",
    "nuxt": "3.0.0",
    "nuxt-electron": "^0.4.5",
    "prisma": "4.7.1",
    "typescript": "^4.9.3",
    "vite-plugin-vuetify": "^1.0.1"
  },

Upgraded to nuxt-electron@latest, had to add vite-electron-plugin after that. Electron works as far as i can see, but if i try import node-7z-archive i get same error.
Im starting to feel that its some kind of conflict with node-7z-archive since i used require to try other package and it worked just fine.

commented

Yes it seems more like a problem with the package, I found this issue on the repo but I'm not sure whether that can help you: TheTechsTech/node-7z-archive#1

Tested a bit more, and other libraries are being imported without problems. I will close the issue as its not related to repository.