6 ms·
Not sails-specific, but sudo npm -g install sails Why do so many projects require sudo? Why are we writing to any area which would require root write privile
by mgkimsal 13y ago
Not sails-specific, but
sudo npm -g install sails
Why do so many projects require sudo? Why are we writing to any area which would require root write privileges? Why do we not default to just writing stuff in to user home directories and patching off that?
Possibly naive question, but one which is increasingly bugging me.
- deleted 13y ago[deleted]
- mistercow 13y agoMy understanding is that npm defaults to putting its install directory somewhere that requires root access. So you see this with the -g option since that puts it in the root npm directory.
- dspillett 13y agoThe -g option in NPM means "install globally" (i.e. system wide) instead of in this projects modules directory. You will always need root privs for that, for any module. Without the -g option sudo is usually not required.
- mAritz 13y agoThat depends on how you install your node/npm. For nvm installs the default is ~/.npm which doesn't require root privileges but is user specific.
- jnycs 13y agoSeems like it's just for convenience? It does get inconvenient to not install things globally with npm and having to run: ./node_modules/.bin/<packageNameHere> every time (or to alias every package)
- progx 13y agoI think on github https://github.com/isaacs/npm/issues https://github.com/isaacs/npm/issues is the right place to ask this, or tho add a feature request. "-g" ist for global installations and you want a "-l" for user local installation.
- IsaacSchlueter 13y ago-l does not mean "local". -l means "--long" and has no relevance to the install command. Local is the default state. If you want to force non-globalness, you can do `--no-global`
- bacongobbler 13y agoIf you want to install npm for user-specific installations (such as when you don't want to require root access when installing an npm module, or that the computer is shared), you can download the NodeJS tarball, and run ./configure --prefix=/home/user/local Which should install into your ~/local directory after running 'make && make install'.
- wicknicks 13y agoYou can always change the destination directory. I usually store my project dependencies locally, so this command works fine: npm install sails This command would store the libs in ./node_modules directory [1]. [1] http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/ http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-in...
- ccarpenterg 13y agoAs a best practice you could use a package.json file [1], IMHO. [1] https://npmjs.org/doc/json.html https://npmjs.org/doc/json.html