2025-04-10 14:36:22 -07:00
.TH "NPM-ROOT" "1" "April 2025" "NPM@11.3.0" ""
2011-11-26 09:21:03 -08:00
.SH "NAME"
2022-12-06 22:18:33 -05:00
\fB npm-root\fR - Display npm root
.SS "Synopsis"
2014-09-24 14:41:07 -07:00
.P
.RS 2
2014-11-04 15:08:12 -08:00
.nf
2022-02-24 21:41:49 +00:00
npm root
2014-11-04 15:08:12 -08:00
.fi
2014-09-24 14:41:07 -07:00
.RE
2023-01-16 22:38:23 -05:00
.P
Note: This command is unaware of workspaces.
2022-12-06 22:18:33 -05:00
.SS "Description"
2014-09-24 14:41:07 -07:00
.P
2022-12-06 22:18:33 -05:00
Print the effective \fB node_modules\fR folder to standard out.
2020-12-11 18:54:56 -05:00
.P
2022-12-06 22:18:33 -05:00
Useful for using npm in shell scripts that do things with the \fB node_modules\fR folder. For example:
2020-12-11 18:54:56 -05:00
.P
.RS 2
.nf
#!/bin/bash
2022-12-06 22:18:33 -05:00
global_node_modules="$(npm root --global)"
2020-12-11 18:54:56 -05:00
echo "Global packages installed in: ${global_node_modules}"
.fi
.RE
2022-12-06 22:18:33 -05:00
.SS "Configuration"
.SS "\fBglobal\fR"
2021-05-20 15:54:50 -04:00
.RS 0
2022-12-06 22:18:33 -05:00
.IP \(bu 4
2021-05-20 15:54:50 -04:00
Default: false
2022-12-06 22:18:33 -05:00
.IP \(bu 4
2021-05-20 15:54:50 -04:00
Type: Boolean
2022-12-06 22:18:33 -05:00
.RE 0
2021-05-20 15:54:50 -04:00
.P
2022-12-06 22:18:33 -05:00
Operates in "global" mode, so that packages are installed into the \fB prefix\fR folder instead of the current working directory. See npm help folders for more on the differences in behavior.
2021-05-20 15:54:50 -04:00
.RS 0
2022-12-06 22:18:33 -05:00
.IP \(bu 4
packages are installed into the \fB {prefix}/lib/node_modules\fR folder, instead of the current working directory.
.IP \(bu 4
bin files are linked to \fB {prefix}/bin\fR
.IP \(bu 4
man pages are linked to \fB {prefix}/share/man\fR
.RE 0
2021-05-20 15:54:50 -04:00
2022-12-06 22:18:33 -05:00
.SS "See Also"
2014-09-24 14:41:07 -07:00
.RS 0
2022-12-06 22:18:33 -05:00
.IP \(bu 4
2019-11-18 21:01:39 +02:00
npm help prefix
2022-12-06 22:18:33 -05:00
.IP \(bu 4
2019-11-05 14:55:08 -05:00
npm help folders
2022-12-06 22:18:33 -05:00
.IP \(bu 4
2019-11-18 21:01:39 +02:00
npm help config
2022-12-06 22:18:33 -05:00
.IP \(bu 4
2019-11-05 14:55:08 -05:00
npm help npmrc
2022-12-06 22:18:33 -05:00
.RE 0