npm-prefix

显示前缀

选择命令行版本:

概要

🌐 Synopsis

npm prefix

注意:此命令不支持工作区。

🌐 Note: This command is unaware of workspaces.

描述

🌐 Description

将本地前缀打印到标准输出。这是最接近的包含 package.json 文件或 node_modules 目录的父目录,除非也指定了 -g

🌐 Print the local prefix to standard output. This is the closest parent directory to contain a package.json file or node_modules directory, unless -g is also specified.

如果指定了 -g,这将是全局前缀的值。更多详细信息请参见 npm config

🌐 If -g is specified, this will be the value of the global prefix. See npm config for more detail.

示例

🌐 Example

npm prefix
/usr/local/projects/foo
npm prefix -g
/usr/local

配置

🌐 Configuration

global

  • 默认:否
  • 类型:布尔

以“全局”模式运行,因此软件包会安装到 prefix 文件夹中,而不是当前工作目录。有关行为差异的更多信息,请参见 folders

🌐 Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See folders for more on the differences in behavior.

  • 软件包被安装到 {prefix}/lib/node_modules 文件夹中,而不是当前工作目录。
  • bin 文件与 {prefix}/bin 关联
  • 手册页已链接到 {prefix}/share/man

也可以看看

🌐 See Also