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: Windows unable to run prettier from node_modules #236

Closed
1 task done
bartektelec opened this issue Dec 5, 2023 · 7 comments
Closed
1 task done

bug: Windows unable to run prettier from node_modules #236

bartektelec opened this issue Dec 5, 2023 · 7 comments
Labels
bug Something isn't working P1 May get worked on if I get free time. PRs welcome

Comments

@bartektelec
Copy link

bartektelec commented Dec 5, 2023

Neovim version (nvim -v)

0.9,1

Operating system/version

Windows 11 22H2

Add the debug logs

  • I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.

Log file

Formatter 'prettier' error in jobstart: Vim:E903: Process failed to start: no such file or directory: "D:/projects/projectName/src/ClientApp/node_modules/.bin/prettier"

Describe the bug

Conform wasn't able to run prettier of node_modules, same thing happened on two different PCs.
There was a file called "prettier" (together with prettier.cmd and prettier.ps1) in my node_modules/.bin but it couldn't run it. I ended up overriding conform's util.lua file and added .. ".cmd" at the end of the path. After that it started running just fine.

Steps To Reproduce

  1. Run neovim with LazyVim basic setup on a Windows machine
  2. Add formatting.prettier through LazyExtras
  3. Try format any TypeScript file.

Expected Behavior

Should just format the file as usual

Minimal example file

No response

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/conform.nvim",
    config = function()
      require("conform").setup({
        log_level = vim.log.levels.DEBUG,
        -- add your config here
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

running of git-bash / zsh

@bartektelec bartektelec added the bug Something isn't working label Dec 5, 2023
@stevearc stevearc added the P1 May get worked on if I get free time. PRs welcome label Dec 6, 2023
@radlinskii
Copy link

radlinskii commented Dec 6, 2023

I have the exact same problem on my machine

Edit: I have this problem while running GitBash, on Powershell it's working as expected.

@bartektelec
Copy link
Author

@radlinskii

what i did is i went to ~/AppData/Local/nvim-data/lazy/conform.nvim/lua/conform/util.lua and changed line 7 to

  return M.find_executable({ "node_modules/.bin/" .. cmd .. ".cmd" }, cmd)

@GitMurf
Copy link

GitMurf commented Dec 22, 2023

I have a related error with Windows path issues but actually think it is a bit different. If I have a space in my path at all of my git repository (where prettier is installed in node_modules) then I get the following error:

image

Notice the actual start to my path to my git repo locally has a space here which is exactly where the error above cutoff.

image

@GitMurf
Copy link

GitMurf commented Dec 22, 2023

If I take the exact same project and simply clone it to like c:/temp on my windows machine (no spaces then in path) then everything works fine.

@stevearc
Copy link
Owner

I believe the issue with using the .cmd binary should be fixed. @GitMurf please file a new issue if you're still having trouble with spaces in the path

@GitMurf
Copy link

GitMurf commented Dec 24, 2023

@stevearc thanks! I will test this afternoon and let you know.

@GitMurf
Copy link

GitMurf commented Dec 26, 2023

@stevearc it is still not working so I opened a new issue #252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 May get worked on if I get free time. PRs welcome
Projects
None yet
Development

No branches or pull requests

4 participants