question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remix + mdx-bundler, getting error ERROR: [plugin: @mdx-js/esbuild] TypeError: this.replace is not a function

See original GitHub issue

Repo for repro

https://github.com/jacargentina/my-remix

npm install
remix dev
open http://localhost:3000
Write some text... clic Convert

Error

 ERROR: [plugin: @mdx-js/esbuild] TypeError: this.replace is not a function

Notes

Using react 18; plus remix.config.js with serverDependenciesToBundle setting When using react 17 it worked. Maybe related to react 18?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
ToniMaundecommented, Jun 17, 2022

I have similar errors as @ToniMaunde.

All I want to do is to bundle some markdown inside loader function and then in the same file in client I want to use that markdown as component.

Got rid of the error by moving the function that was responsible for calling bundleMDX to a fileName.server.ts file. This is to prevent Remix from running backend code on the browser. Explanation here.

After that I got a new message

mdx-bundler warning: esbuild maybe unable to find its binary, if your build fails you'll need to set ESBUILD_BINARY_PATH.

and it contained a link to how I could fix it.

I have this code at the top of my fileName.server.ts and the errors are gone. 😌

function fixEsbuildBinaryError() {
  if (process.platform === 'win32') {
    process.env.ESBUILD_BINARY_PATH = path.join(
      process.cwd(),
      'node_modules',
      'esbuild',
      'esbuild.exe',
    )
  } else {
    process.env.ESBUILD_BINARY_PATH = path.join(
      process.cwd(),
      'node_modules',
      'esbuild',
      'bin',
      'esbuild',
    )
  }
}

fixEsbuildBinaryError();
2reactions
kwiat1990commented, Jun 15, 2022

I have similar errors as @ToniMaunde.

All I want to do is to bundle some markdown inside loader function and then in the same file in client I want to use that markdown as component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

var.replace is not a function - javascript - Stack Overflow
My guess is that the code that's calling your trim function is not actually passing a string to it. To fix this, you...
Read more >
Why am I getting "TypeError: e.replace is not a function" using ...
Why am I getting "TypeError: e.replace is not a function" using SearchManager with eval in the search? ... new SearchManager({ id: "mysearch1", earliest_time:...
Read more >
How to fix "Uncaught TypeError: x is not a function" in JavaScript
JS Casts 01 - How to fix "Uncaught TypeError : x is not a function " in JavaScript.Visit https://javascriptcasts.com/episodes/01 for a summary ...
Read more >
this.replace is not a function on DataBind - jQWidgets
When i open the page (Sharepoint Webpart) i get an error: TypeError: this.replace is not a function return this.replace(/^\s+|\s+$/g, '');.
Read more >
Fixing webpack error - request.replace is not a function
Fixing webpack error: TypeError: request.replace is not a function. If you try to set up multiple entry points in Webpack, you can get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found