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

More helpful error message when encountering missing modules while reading .miyagi.js #388

Open
schalkneethling opened this issue Jul 11, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@schalkneethling
Copy link

I just installed the extension in VSCode and got the following error:

2024-07-11 22:24:09.496 [info] Error: Cannot find module '@miyagi/twig-drupal'

VSCode Details

Version: 1.91.0 (Universal)
Commit: ea1445cc7016315d0f5728f8e8b12a45dc0a7286
Date: 2024-07-01T18:54:18.541Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0
@mvsde mvsde self-assigned this Jul 12, 2024
@mvsde
Copy link
Member

mvsde commented Jul 12, 2024

Thank you for reporting. This usually means that npm dependencies are not yet installed and the extension encountered a missing module when trying to read the .miyagi.js configuration.

Can you try installing npm dependencies and then run the “miyagi: Reload” command from the VS Code Command Palette?

I’ll put it on my to do list to output a more helpful error message with the above-mentioned information.

@mvsde mvsde added the enhancement New feature or request label Jul 12, 2024
@mvsde mvsde changed the title Error after installing in VSCode - Version: 1.91.0 (Universal) More helpful error message when encountering missing modules while reading .miyagi.js Jul 12, 2024
@schalkneethling
Copy link
Author

miyagi: Reload

Aha! I found what the problem was here. I installed it at the root of a Circle Dot based project. Here it throws the error no matter whether the dependencies are already installed or not. When I open VSCode to just the relevant theme (web/themes/custom/theme), everything works as expected.

I wonder whether one could add the ability to provide a setting that is the path to a theme directory and the extension would then look for the NPM modules inside this directory. I would be happy to contribute if this makes sense. Thanks!

@mvsde
Copy link
Member

mvsde commented Jul 15, 2024

In theory the extension supports miyagi projects that are not in the root folder and even multiple projects opened at the same time.

The extension searches for all .miyagi.js or .miyagi.json files in the currently opened workspace and uses the miyagi config file to determine what a “project root” is:

const configURIs = await vscode.workspace.findFiles(MIYAGI_CONFIG_GLOB, EXCLUDE_GLOB)

I’m not sure why this didn’t work in your case 🤔

@schalkneethling
Copy link
Author

In theory the extension supports miyagi projects that are not in the root folder and even multiple projects opened at the same time.

The extension searches for all .miyagi.js or .miyagi.json files in the currently opened workspace and uses the miyagi config file to determine what a “project root” is:

const configURIs = await vscode.workspace.findFiles(MIYAGI_CONFIG_GLOB, EXCLUDE_GLOB)

I’m not sure why this didn’t work in your case 🤔

I will create a fresh clone over the weekend and try it again to see if I can replicate.

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

No branches or pull requests

2 participants