Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 2.59 KB

nvm.md

File metadata and controls

41 lines (30 loc) · 2.59 KB

NVM

Overview

Some of the external tools used by this plugin (e.g. elm-format and elm-test) rely on node. In order for the plugin to fully function, it needs to be able to execute node from within the IntelliJ environment. In most cases it will be able to do this because when node is installed, it is put on the system path. However, if node is installed using nvm then, depending on how IntelliJ is launched, this might not be the case.

Symptoms

The Elm plugin's Settings screen allows you to specify a path to various Elm tools.

  • Pressing the Auto Discover button should find the appropriate tool, but it may fail to find tools installed by nvm
  • Even if a valid path to a tool is provided, you may see an error like: /usr/bin/env: 'node': No such file or directory

Cause

This is due to the way nvm adds node to the path by making some updates to your shell's login profile (e.g. ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc), as explained here. If, for example, it makes these changes to ~/.bashrc, node will only be on the path when that file is processed, i.e. when a bash shell is started. In this situation, if IntelliJ is launched without the use of a bash shell, it will result in node not being on the path within the IntelliJ environment. This commonly happens when you launch IntelliJ from your OS's desktop UI (e.g. Windows Start menu, macOS Dock, Gnome).

Solution

To resolve the problem above, IntelliJ needs to be launched in such a way that node will be on the path. One simple solution is to manually launch it from within a shell which has already processed the relevant configuration file, e.g. from within a bash shell, if .bashrc was where the nvm install updated the path.

Linux

If launching IntelliJ from a .desktop file (e.g. if it was installed by snap), update the Exec line so that instead of directly launching IntelliJ, it instead launches a shell such as bash, and gets it to then launch IntelliJ:

Exec=/bin/bash -ic "/snap/bin/intellij-idea-ultimate %f" 

Note that in this example, the -ic argument is important, specifically the i flag: this launches bash in interactive mode, which is what causes bash to process .bashrc, as explained here