"npm root" locates the global node modules directory (#tilPost)

Today I learned that the npm root command locates the local and global node_modules directory.
Finding local dependencies isn’t very spectacular because they’re usually located in ./node_modules. But locating the global dependencies…


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

Today I learned that the npm root command locates the local and global node_modules directory.

Finding local dependencies isn't very spectacular because they're usually located in ./node_modules. But locating the global dependencies can be a hassle. People install Node.js in countless ways, and that's why the Node.js binary and the global dependencies can be anywhere.

It's great to learn that there's a command that helps locate the global dependencies!

From the npm docs:

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

And I just had a use case for npm root. Beautiful!


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2021-10-19T22:00:00+00:00) "npm root" locates the global node modules directory (#tilPost). Retrieved from https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/

MLA
" » "npm root" locates the global node modules directory (#tilPost)." Stefan Judis | Sciencx - Tuesday October 19, 2021, https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/
HARVARD
Stefan Judis | Sciencx Tuesday October 19, 2021 » "npm root" locates the global node modules directory (#tilPost)., viewed ,<https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » "npm root" locates the global node modules directory (#tilPost). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/
CHICAGO
" » "npm root" locates the global node modules directory (#tilPost)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/
IEEE
" » "npm root" locates the global node modules directory (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/. [Accessed: ]
rf:citation
» "npm root" locates the global node modules directory (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2021/10/19/npm-root-locates-the-global-node-modules-directory-tilpost/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.