0

I'm using tiptap in my Quasar app with the node CodeBlockLowlight enabled.

Running the dev server works just fine with quasar dev --mode ssr --port 9000. THe project builds and I'm able to work on my project without any issues.

Now, whenever I try to start the node server with the following command ENV_FILE=test quasar build --mode ssr --port 3000 && node dist/ssr/index.js it gives the following errors:

internal/modules/cjs/loader.js:1102
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/whatever/devotto/devotto.com/node_modules/lowlight/lib/core.js
require() of ES modules is not supported.
require() of /home/whatever/devotto/devotto.com/node_modules/lowlight/lib/core.js from /home/whatever/devotto/devotto.com/dist/ssr/server/server-entry.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename core.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/whatever/devotto/devotto.com/node_modules/lowlight/package.json.

Here is my package.json

{
  ...
  "dependencies": {
    "@quasar/extras": "^1.0.0",
    "@tiptap/extension-code-block-lowlight": "^2.0.0-beta.209",
    "lowlight": "^2.8.0",
    "@tiptap/vue-3": "2.0.0-beta.204",
  }
}

What I have tried

After reading the following resources:

I have:

  • tried to lower the version of lowlight all the way to 1.20.0
  • tried to add "type": "module" to my package.json

So far I wasn't able to build my project and start a node server so I can run my E2E tests.

Why am I getting this error and how I can solve it?

Bruno Francisco
  • 3,841
  • 4
  • 31
  • 61

0 Answers0