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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.