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

VSCode Extension cannot find packages indicated in tsconfig.json #442

Closed
4 tasks done
Icexist opened this issue May 21, 2024 · 8 comments
Closed
4 tasks done

VSCode Extension cannot find packages indicated in tsconfig.json #442

Icexist opened this issue May 21, 2024 · 8 comments
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem

Comments

@Icexist
Copy link

Icexist commented May 21, 2024

Initial checklist

Affected packages and versions

v1.8.6

Link to runnable example

No response

Steps to reproduce

When using the MDX plugin in VSCode, set the tsconfig.json file to have any number of plugins and try to open an mdx file.

It works just fine with the 1.8.5 version (installed via "install other version" in vscode)

my tsconfig.json file:

{
  "include": ["**/*"],
  "compilerOptions": {
    // …
  },
  "mdx": {
    "plugins": [
      "remark-frontmatter",
      "remark-gfm",
      "remark-math",
      "rehype-katex"
    ]
  }
}

Expected behavior

MDX should work as expected.

Actual behavior

The MDX plugin crashes:

Error: Cannot find package 'remark-frontmatter' imported from /home/xxxx/project
at new n (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:858:18648)
at Sq (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:7076)
at Xle (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:7581)
at Eq (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:8808)
at Gv (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:8998)
at Lq (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:10157)
at async Kv (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:860:9400)
at async Promise.all (index 0)
at async s (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:865:18826)
at async sae (/home/xxxx/.vscode-server/extensions/unifiedjs.vscode-mdx-1.8.6/out/language-server.js:96:5817) {
code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.18.2
[Error - 4:13:18 PM] Server process exited with code 1.
[Error - 4:13:18 PM] The MDX server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Runtime

No response

Package manager

No response

OS

Windows 10, running VSCode remote in a WSL2 instance. MDX plugin runs on the WSL instance.

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 21, 2024
@Icexist Icexist changed the title Cannot find packages indicated in tsconfig.json VSCode Extension cannot find packages indicated in tsconfig.json May 21, 2024
@remcohaszing
Copy link
Member

In version 1.8.0-1.8.5 there was a bug that caused the language server to ignore the plugins field. So it defaulted to ["remark-frontmatter", "remark-gfm"]. That’s why this worked for you kind of by accident.

You should specify "remark-math", because it adds support for parsing the math syntax, but not "rehype-katex", as this only transforms the AST.

Do you have all those plugins installed in /home/xxxx/project? In other words: Does /home/xxxx/project/node_modules/remark-frontmatter exist and can you import remark-frontmatter from /home/xxxx/project/some-script.mjs? with the following contents:

import 'remark-frontmatter'

@remcohaszing remcohaszing added 🙉 open/needs-info This needs some more info 📎 platform/windows This affects Windows labels May 23, 2024
Copy link
Contributor

github-actions bot commented May 23, 2024

Hi! Thanks for taking the time to contribute! This has been marked by a maintainer as needing more info. It’s not clear yet whether this is an issue. Here are a couple tips:

  • Spend time framing the issue! The more time you put into it, the more we will
  • Often, maintainers respond with why for several back and forths; rubber duck debugging might help avoid that
  • Folks posting issues sometimes fall for xy problems: asking for a certain solution instead of raising the root problem

Thanks,
— bb

@Icexist
Copy link
Author

Icexist commented May 23, 2024

Verify that those (and more) are in node_modules:
image

I'm running Docusaurus, so i'm not fully clear on how to test the .mjs file, but these extensions work just fine in Docusaurus.

Still have the same problems after removing rehype-katex - the extension can't find the modules.

Here's a fresh repository that shows the issue for me: https://github.com/Icexist/mdx-ext-debug

There is a file docs\test.mdx that triggers the issue.

@Icexist
Copy link
Author

Icexist commented May 23, 2024

As a note, that repo was created on MacOS and showed the issue in VSCode there, so this isn't limited to Windows.

@remcohaszing
Copy link
Member

Thanks for the reproduction. I’m able to reproduce this on Linux too.

@remcohaszing remcohaszing added 🐛 type/bug This is a problem 🗄 area/interface This affects the public interface 👶 semver/patch This is a backwards-compatible fix 👍 phase/yes Post is accepted and can be worked on and removed 🙉 open/needs-info This needs some more info 📎 platform/windows This affects Windows 🤞 phase/open Post is being triaged manually labels May 24, 2024

This comment has been minimized.

This comment has been minimized.

@remcohaszing remcohaszing added the 💪 phase/solved Post is done label May 27, 2024
@github-actions github-actions bot removed 👍 phase/yes Post is accepted and can be worked on 🙆 yes/confirmed This is confirmed and ready to be worked on labels May 27, 2024
@remcohaszing
Copy link
Member

This was fixed in version 1.8.7 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants