Manage Node versions within Emacs using fnm (Fast Node Manager).
Add fnm to your Cask file:
(depends-on "fnm")(use-package fnm
:ensure t
:config
;; Optionally set a default node version
(fnm-use "22"))Using use-package and straight.el
(use-package fnm
:straight (:host github :repo "nhojb/fnm.el")
:config
;; Optionally set a default node version
(fnm-use "22"))Using Quelpa
(use-package fnm
:quelpa ((fnm :fetcher github
:repo "nhojb/fnm.el")
:upgrade t))Activate version. If callback is specified, use version in that
callback and then switch back to the previously used version.
Version can be a full version (e.g., "v22.18.0"), major.minor (e.g., "22.18"), or just major (e.g., "22"). The most recent matching installed version will be used.
Read version from .fnmrc, .nvmrc, or .node-version file in path (or
default-directory) and activate it. Files are checked in that order of
precedence. Second callback argument is same as for fnm-use.
Call fnm-use-for on the file visited by the current buffer. Suitable
for use in a mode hook to automatically activate the correct Node
version for a file.
Example:
(add-hook 'js-mode-hook #'fnm-use-for-buffer)The fnm installation directory. Defaults to ~/.local/share/fnm or the
value of the FNM_DIR environment variable.
Contribution is much welcome!
Install cask if you haven't already, then:
$ cd /path/to/fnm.el
$ cask
Run all tests with:
$ make
fnm.el is based on nvm.el