Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On NodeJS - TypeError: Cannot process without Compiler #63

Open
janaka opened this issue Jul 17, 2022 · 4 comments
Open

On NodeJS - TypeError: Cannot process without Compiler #63

janaka opened this issue Jul 17, 2022 · 4 comments

Comments

@janaka
Copy link

janaka commented Jul 17, 2022

Hi,
Thanks for everybody's efforts on this project.

I've been having issues getting it to work on NodeJS and all things point to the issue being with remark-slate with Node. The same code worked fine in the browser within a React app. I want to use this on the backend to handle read/write from markdown persistence.

I've tried debugging myself but haven't made much progress. I've also tried different versions of dependencies with no luck.

Seems like somebody else has had issues trying to use for a similar use case. See thread here.

fwiw I seem to be making a bit more progress with remark-slate-transformer.

Any ideas?

Much appreciated.

My test code

  unified()
    .use(remarkParse)
    .use(remarkSlate)
    .process('[my link](https://github.com)', (err, file) => {
      if (err) throw err;
      if (!file) throw "file is undefined"
      console.log(file);
    });

The error thrown by Unified.
node_modules/unified/lib/index.js:520 the assertCompiler function.

TypeError: Cannot `process` without `Compiler`

with ESM + Typescript

@woodpeng
Copy link

woodpeng commented Jul 22, 2022

I uncounted the same err.

I import the remark-slate with:
const slate = require('remark-slate');

Then resolve the error with:

unified()
   .use(remarkParse)
   .use(slate.default)

@hanford
Copy link
Owner

hanford commented Jul 22, 2022

@woodpeng interesting, is this an issue with how I'm distributing the module? If so that sounds like an easy fix

@woodpeng
Copy link

Since my project using CommonJs instead of ESM, I have to use 'require' to import the module. I am not sure whether this change caused the err, then have to add the '.default' to make it work.

@andrew-st-angelo-dockethq

I too am receiving the Cannot `process` without `Compiler` . I've imported remark-slate, as part of an ESM. And using the .default trick prevents the error from being thrown but my export remains in Markdown.

await unified().use(remarkParse).use(remarkSlate.default).process('[my link](https://github.com)');

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants