iamcco / markdown-preview.nvim

markdown preview plugin for (neo)vim
MIT License
6.67k stars 277 forks source link

Node.js Compatibility Issue with Markdown Preview on Windows 10 in MSYS 2 #667

Closed GitHubonline1396529 closed 5 months ago

GitHubonline1396529 commented 5 months ago

Environment

Description

Brief Description

I am encountering an issue where markdown-preview.nvim does not function as expected. I have set up everything according to the documentation, but when I attempt to use the :MarkdownPreview command in vim launched in MSYS2's shell, it fails without providing any error messages beyond a note about Node.js v18.17.0.

Expected Behavior

The plugin should initialize and open a markdown preview window in the browser without any errors.

Actual Behavior

When executing :MarkdownPreview within vim launched in MSYS2's shell, the operation fails with no detailed error message, only indicating an issue with Node.js v18.17.0. However, this issue does not occur when using PowerShell or from the context menu.

Steps to Reproduce

  1. Install Node.js v18.17.0 independently (not through MSYS2).
  2. Install Gvim 9.0 using the official installer.
  3. Set up vim-plug as the plugin manager and add iamcco/markdown-preview.nvim to the .vimrc configuration:
call plug#begin('~/.vim/plugged')
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
call plug#end()
  1. Run Vim and execute:
:PlugInstall
:MarkdownPreview
  1. The preview fails to launch, only outputting the error related to Node.js v18.17.0.

An Image

error

Additional Information

Here are some of my attempts: running the following commands in MSYS2's shell all ends up with the same error.

start gvim ./file.md
pwsh -c "gvim ./file.md"
powershell -c "gvim ./file.md"
start pwsh -c "gvim ./file.md"
start powershell -c "gvim ./file.md"

Also I've tried to install node.js in MSYS2 with pacman:

$ pacman -S mingw-w64-ucrt-x86_64-nodejs

...

$ where node
/ucrt64/bin/node
/d/nodejs/node

and the only difference is that the error message became Node.js v21.6.2.

Logs

Didn't find any logs.

GitHubonline1396529 commented 5 months ago

If here's more imformation about the error, I think, maybe I can fix it myself?

However, the only thing I know is Node.js v18.17.0 and I don't know what does that means...

nodu commented 5 months ago

Did you recently update node? I was having the same issue. I was able to get this working again by removing the plugin then re-adding it. I figure this re-triggered the plugin's build step, "cd app && npm install". Hope that helps @GitHubonline1396529 !

GitHubonline1396529 commented 5 months ago

Did you recently update node? I was having the same issue. I was able to get this working again by removing the plugin then re-adding it. I figure this re-triggered the plugin's build step, "cd app && npm install". Hope that helps @GitHubonline1396529 !

Hi @nodu,

Thank you SO MUCH for your suggestion! Although I'm not a Javascriptist and knew nothing about Node.js, you reminded me to check the plugin folder which Node.js supposed to build the project in and, yes, I've found a resolution to this issue, and here it is:

Solution

1. Environment Specifics

When using vim-plug in MSYS2, Vim creates a new .vim directory under MSYS2's /home directory rather than using the default Windows 10 .vim directory located at C:\Users\<userName>\.vim\. This led to two separate instances of the same plugin being installed without interfering with each other.

2. What I Did

While checking the plugin folder under MSYS2's /home I found a childfolder named bin there with no Binary files in it, so I download markdown-preview-win.exe in GitHub Releases and manually added the markdown-preview-win.exe binary to the ~/.vim/plugged/markdown-preview.nvim/app/bin directory.

This action corrected the plugin's functionality, suggesting that the binary file was not automatically placed or built during the plugin's installation process through :PlugInstall.

3. Possible Cause