npm-root

显示 npm root

选择命令行版本:

概要

🌐 Synopsis

npm root

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

🌐 Note: This command is unaware of workspaces.

描述

🌐 Description

将有效的 node_modules 文件夹打印到标准输出。

🌐 Print the effective node_modules folder to standard out.

在使用 npm 处理 node_modules 文件夹的 shell 脚本中非常有用。例如:

🌐 Useful for using npm in shell scripts that do things with the node_modules folder. For example:

#!/bin/bash
global_node_modules="$(npm root --global)"
echo "Global packages installed in: ${global_node_modules}"

配置

🌐 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