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

[BUG with Solution] :MarkdownPreview prints Node.js v22.6.0 and does nothing #695

Open
iamhrigved opened this issue Aug 23, 2024 · 4 comments

Comments

@iamhrigved
Copy link

iamhrigved commented Aug 23, 2024

Describe the bug

I installed this plugin with the following setup

{
    "iamcco/markdown-preview.nvim",
    cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
    ft = { "markdown" },
    build = function() vim.fn["mkdp#util#install"]() end,
}

When I tried to run :MarkdownPreview it just printed Node.js v22.6.0 and did nothing.

To Reproduce

Steps to reproduce the behavior:

  1. Add the plugin with lazy
  2. Open a markdown file
  3. Do :MarkdownPreview

Expected behavior

A browser window should open with the preview of the markdown file.

Desktop

  • OS: Arch Linux
  • WM: Hyprland
  • Browser: Brave Browser

Solution

I saw this issue and tried the following:

cd ~/.local/share/nvim/lazy/markdown-preview.nvim
npm install

I then tried to do MarkdownPreview and it worked !!!

@crolbar
Copy link

crolbar commented Aug 27, 2024

maybe a better solution would be to do something like this:

build = "npm install",

or

build = "cd app && yarn install",

@stevenwalton
Copy link

This initially provided a fix and then I started getting Pre build and node is not found.

I use Plug and I tried via the commands listed in the README as well as issuing manually. I tried deleting and reinstalling. This seems to sometimes work and sometimes fail (after initially working). Output always looked like this regardless of working or failing

$ rm -r ~/.vim/plugged/markdown-preview.nvim
$ vim -c "PlugInstall" -c "qa"
yarn install v1.22.22
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
✨  Done in 0.26s.
$ vim ~/.dotfiles/README.md -c "MarkdownPreview"

So if other users are experiencing this, I'm not sure what to say but maybe try a few times. There's clearly something else afoot but might need more reports to find the right cause.

This was done on a M2 Mac Air

@stevenwalton
Copy link

FWIW I upgraded to Sequoia and this broke again. Tried a full reinstall and nothing. yarn's output looks exactly like before.

Opposite34 referenced this issue in Opposite34/dotconfig-neovim Sep 27, 2024
@Opposite34
Copy link

Opposite34 commented Sep 27, 2024

I haven't tried this (my system needed the npx workaround at #690 so I couldn't try it), but the line after vim.fn["mkdp#util#install"]() try add this: vim.cmd("!cd " .. plugin.dir .. " && npm install") so it'd be:

build = function() 
    vim.fn["mkdp#util#install"]()
    vim.cmd("!cd " .. plugin.dir .. " && npm install")
    end,

Speaking of #690 , if you're using that workaround with npx, try this for the build command. This one I've tested to be working for my system:

    build = function(plugin)
        if vim.fn.executable "npx" then
            vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install && npm install")
        else
            vim.cmd [[Lazy load markdown-preview.nvim]]
            vim.fn["mkdp#util#install"]()
        end
    end,

(essentially vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install && npm install") also has npm install at the end now)

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