← 返回命令列表

Linux command

npm-exec 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run a local package binary

npm exec [command]

Run a command with arguments

npm exec -- [command] [args]

Run a package from the registry

npm exec -p [package] -- [command]

Run a specific package version

npm exec -p [package]@[version] -- [command]

Run with multiple packages available

npm exec -p [pkg1] -p [pkg2] -- [command]

Run a shell command string in the package environment

npm exec -c '[shell_command]'

Auto-accept installation prompts for remote packages

npm exec -y -p [package] -- [command]

说明

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.

参数

-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.

FAQ

What is the npm-exec command used for?

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.

How do I run a basic npm-exec example?

Run `npm exec [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p, --package _pkg_ do in npm-exec?

Package to install (can be specified multiple times).