LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

npm-exec

Run a command from a local or remote npm package

TLDR

Run a local package binary
$ npm exec [command]
copy
Run a command with arguments
$ npm exec -- [command] [args]
copy
Run a package from the registry
$ npm exec -p [package] -- [command]
copy
Run a specific package version
$ npm exec -p [package]@[version] -- [command]
copy
Run with multiple packages available
$ npm exec -p [pkg1] -p [pkg2] -- [command]
copy
Run a shell command string in the package environment
$ npm exec -c '[shell_command]'
copy
Auto-accept installation prompts for remote packages
$ npm exec -y -p [package] -- [command]
copy

SYNOPSIS

npm exec [options] [-- command [args...]]

DESCRIPTION

npm exec runs a command from a local or remote npm package. It is similar to npx but integrated directly into the npm CLI. The command can run locally installed packages or temporarily download and execute packages from the npm registry.The double dash (--) separates npm exec options from the command and its arguments. Without --, npm may interpret arguments as its own options. When run without positional arguments or --call, it opens an interactive shell with the package environment configured in the PATH.When --package is not specified, npm exec will try to determine the executable from the first positional argument, matching it against packages in the local project or the npm registry.

PARAMETERS

-p, --package pkg

Package to install (can be specified multiple times).
-c, --call cmd
Shell command string to run in the package environment.
-y, --yes
Skip confirmation prompts when downloading remote packages.
--no
Refuse to install packages not already available locally.
-w, --workspace name
Run in the context of the specified workspace.
--workspaces
Run in the context of all configured workspaces.
--include-workspace-root
Include the workspace root when using --workspaces.

INSTALL

sudo pacman -S npm
copy
sudo apk add npm
copy
brew install npm
copy

CAVEATS

Unlike npx, npm exec requires -- before the command when passing arguments. May prompt for confirmation when downloading remote packages unless -y or --no is specified. The --call option runs the command in a shell, so shell syntax like pipes and redirects is supported.

HISTORY

npm exec was added in npm 7 as a built-in alternative to npx, providing similar functionality with better npm integration and workspace support.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid