bennymeg / nx-electron

Electron schematics for nrwl nx platform
Apache License 2.0
307 stars 82 forks source link

package command is failing due to unable to import ES module `strip-json-comments` using `require()` #288

Closed yuryturing closed 2 months ago

yuryturing commented 2 months ago

Describe the bug Unable to execute package command after upgrading to nx-electron@18.0.0 due to

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\projects\testing-electron-support\node_modules\nx-electron\node_modul
es\strip-json-comments\index.js from C:\projects\testing-electron-support\node_modules\nx-electron\src\executors\package
\executor.js not supported.

Desktop (please complete the following information):

Root case Dependency version for strip-json-comments has been upgraded ^3.1.1 --> ^5.0.1.

The latest version of the dependency does not support commonjs imports, so transpiled code is not working any more.

const strip_json_comments_1 = tslib_1.__importDefault(require("strip-json-comments"));
joshuamorony commented 2 months ago

Just to note a workaround for now, I was able to get by this by forcing the cjs version of strip-json-comments (using pnpm):

  "pnpm": {
    "overrides": {
      "strip-json-comments": "^3.1.1"
    }
  },
bennymeg commented 2 months ago

Tnx, fixed.