选择命令行版本:
🌐 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/bashglobal_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 文件夹中,而不是当前工作目录。{prefix}/bin 关联{prefix}/share/man🌐 See Also