elm-format
elm-format copied to clipboard
Not working with visual studio code when installed from npm
On the vs code terminal:
npm install elm-format -g
Then reset the terminal. elm-format
works fine when opened in CMD or powershell from any folder. I can use it to format any elm file. However when I select elm format
from the vs code command palette (ctrl+shift+p
) I get the following error:
Nothing actually happens to the code file. Also format on save doesn't work (despite the option being turned on from the workspace settings).
Thanks!
Which VSCode Elm/elm-format plugin(s) are you using? If you are able to run elm-format
from your terminal, then this seems like an issue with the plugin.
VS Code 1.14.2
elm 0.12.1
elm-format 0.1.0
I'm having the same issue. I have installed elm-format with npm, can use elm-format from the command line, have verified that C:\Users\Travis\AppData\Roaming\npm\elm-format.cmd exists and that C:\Users\Travis\AppData\Roaming\npm is in my PATH. I tried restarting vscode and even logging off but vscode is still saying:
Unable to execute elm-format. Please make sure you have elm-format on your PATH
Any ideas are greatly appreciated. Would be great to be able to use elm formatting while I'm learning elm.
You can use elm vscode plugin for formatting elm, after you install it use Alt+Shift+F
(shortcut for "Format Document") to run elm-format.
The instructions in the README are out of date, elm-format has been unpublished from vscode-marketplace
I still have this problem, is there any solution/workaround?
@oren-l this is happening with the elm
vscode plugin, not elm-format
. It still uses the elm-format
package (not vscode plugin).
I have a workaround if this is the same issue as #408
I'm having this same issue on a new project. Something tells me I've solved this before with some VSCode specific configuration but nothing I've tried so far is working yet.
Maybe this us also related to this issue reported for the Elm extension for VSCode? https://github.com/Krzysztof-Cieslak/vscode-elm/issues/275
Any workaround for formatting?
If your running linux, you need to add the full path to your elm-format like /home/razze/.nvm/versions/node/v10.15.3/bin/elm-format
As the path environment that vscode initalizes when you create a child_process with node does not include the nvm (or node?) part of your path variable...
Same problem here =/
I Fixed my problem doing this I upgraded my version of elm-format and its come works now.
PS I changed npm to yarn.
I used yarn to install global follwing this link Yarn
1. yarn config set prefix ~/.yarn (To created a myglobal yarn directory)
2. sudo yarn global add elm-format
3. ls ~/.yarn
4. elm-format
I encountered this issue out of nowhere, tried reinstalling via npm, restarting everything, full path in extension setting but it just wouldn't work.
Turns out elm-format only works for me if I start VS Code from my project directory. I normally open it with code .
and it works but if I start VS Code some other way it doesn't. YMMV. I'm running OS X.