This is pnpm-mode, an Emacs minor mode for working with NPM projects, using pnpm.
The recommended way to install pnpm-mode is through the package manager and MELPA.
Start by cloning the pnpm-mode package repository:
$ git clone https://github.com/rajasegar/pnpm-mode.git /your/path/here
Finish by loading the pnpm-mode package in your emacs configuration:
(add-to-list 'load-path "/your/path/here/pnpm-mode")
(require 'pnpm-mode)
The pnpm-mode package provides a minor mode which can be activated with:
(pnpm-mode)
The mode can be activated globally with:
(pnpm-global-mode)
The mode can be activated on a per-project basis using directory local
variables by running add-dir-local-variable
from the root directory
of a project.
For example, visit the README.md
file in the root directory of a
project, and run M-x add-dir-local-variable. Emacs will
prompt you for Mode or subdirectory:
, to which you should enter
nil
.
Next, you will be prompted for Add directory-local variable:
, to
which you should enter mode
.
Next, you will be prompted for Add mode with value:
, to which you
should enter pnpm-mode
.
Next, you will be placed in a new .dir-locals.el
buffer containing
the directory local variables for the project, including the added
pnpm-mode
configuration.
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((nil
(mode . pnpm)))
Finally, save the buffer contents with C-x C-s, and your
project is configured for pnpm-mode
.
Now when you visit any file under the project directory, pnpm-mode will be activated and its commands made available.
The mode provides a command keymap, whose default C-c n prefix can be configured with M-x customize-variable pnpm-mode-keymap-prefix.
Once pnpm-mode has been activated, its commands are accessed by the C-c n command prefix:
command | keymap | description |
---|---|---|
pnpm-mode-npm-init | n | Initialize new project |
pnpm-mode-pnpm-install | i | Install all project dependencies |
pnpm-mode-pnpm-add | s | Add new project dependency |
pnpm-mode-pnpm-add-dev | d | Add new project dev dependency |
pnpm-mode-pnpm-remove | u | Remove project dependency |
pnpm-mode-pnpm-list | l | List installed project dependencies |
pnpm-mode-pnpm-run | r | Run project script |
pnpm-mode-pnpm-test | t | Run project test script |
pnpm-mode-visit-project-file | v | Visit project package.json file |
? | Display keymap commands |
Running C-c n n will create a new project in the current directory.
Running C-c n i in a project directory will install all project dependencies.
Running C-c n s in a project directory will prompt for the name of a package to install and will install it as a project dependency.
Running C-c n d in a project directory will prompt for the name of a to install and will install it as a project dev dependency.
Running C-c n u in a project directory will prompt for the name of a package to uninstall and will uninstall it and remove it from project dependencies.
Running C-c n U in a project directory will updates packages to their latest version based on the specified range.
Running C-c n t in a project directory will run the test script.
Running C-c n l in a project directory will list the project.
Running C-c n r in a project directory will prompt for the name of a script to run and will run it. Completion support is provided.
Running C-c n v in a project directory will visit the project file in a buffer.
This repo is a rewrite of https://github.com/mojochao/npm-mode
Many thanks to Alen Gooch for his contribution.