Open loveencounterflow opened 9 years ago
Hey @loveencounterflow,
Nice writeup! I also use n for my NodeJS installation. I take it make install
from the n git repo rather than npm install -g n
is for computers without NodeJS already installed? Also, did you mean ~/.npm
instead of ~/npm
? Regarding sudo
and @latest
usage, those were included to mitigate user error as much as possible. The command I use personally is npm install -g slap
, which looks to work for both of us. :P I'd be glad to have this in the slap wiki if you want to add it there!
There's a ~/.npm/
as well as a ~/npm
; I'd have to check but I think ~/.npm
is just an internal cache of npm
to avoid repeated downloads. At he time of writing I totally didn't think about that one and didn't touch it.
To clarify, Step 1 is only meant for users without a working NodeJS install. That said, I put it here b/c (a) slap is an application interesting enough in its own right so it might draw people from other quarters, and they might be as puzzled as me at the range of options to install NodeJS correctly and easily. It is also a piece of advice for people who inadvertently installed NodeJS via apt-get install
(you don't do that with LibreOffice, you don't do that with TeX Live, you don't do that with NodeJS) and who want to repair their install.
I'm short on details here but as I see it sudo
is not a panacea like 'please' or 'do it already' that you throw in whenever something refuses to work. Sometimes this is the way to go, but every time you say sudo x
, you're running a command as root in a different environment and so on. Proof: sudo touch /tmp/xxx
will result in a file that is owned by root, ergo you must run any later commands that are write to that file as root.
Heck I realized I'd just give it a try. TL;DR: Don't sudo npm install
anything (unless you know what you're doing). Test it out: cd /tmp; sudo npm install cnd
(or whatever package). You'll get a file tree with some files owned by root (e.g. all the package.json
files), some files owned by you. Yuck. You don't (completely) own your installation any more, which is contrary to established Best Practices of NodeJS and npm
. For one thing, this will inhibit / seriously hamper your ability to update module dependencies later on. Just don't do that.
Nvm is better than n that I know of. Travis ci uses it and I find it generally works better.
Not a bug report as such, but I thought I might jot down some words to help people that experience difficulties with installing slap (I certainly had some).
1: Install NodeJS
First of all, slap appears to be compatible (so far) with the newest NodeJS (v5 as of this writing). To me, the painlessest way to get the newest versions of Nodejs,
npm
andn
(NodeJS version management, highly recommended) is to follow the outline in my how-to; roughly, clonen
, build it, and use it once to get the newest NodeJS (should come withnpm
v3):I write this because people always ask how to best install NodeJS. Debianists and Ubuntuers don't let their friends install NodeJS with
apt-get
—that will get you an outdated version, naming conflicts, insane file rights setups, what have you.2: Cleanup Global NPM Modules
This one's a biggy: In case you've been running NodeJS for as long as I have, you'll likely have ooogles of global modules installed over the years. Given the fast evolution of both Node and
npm
, there's bound to be some bit rot, so it's time to clear up that space. I was unable to install slap and got all kinds of weird errors until I resolved to manually remove my~/npm/lib/node_modules
folder (actually I renamed it for reference and created a newnode_modules
).3: Install slap
The official slap docs recommend to
sudo npm install -g slap@latest
. Not sure whether thatsudo
gives you important stuff that you don't get without (readers please fill me out on that one), but, generally speaking, the majority of people living on planet NodeJS prefer user-owned installs, user-owned/usr/local
directories, and so on. This also happens to be the way ofhomebrew
, and is generally considered A Good Idea. For this reason, i just didwhich appears to work. Again, not sure what
slap@latest
gives you that you don't get without it; most of the time, you don't add version markers tonpm install
.I can strongly recommend to
npm install -g npm-check
, which will give you the greatest way to controlnpm
dependencies.npm-check -u
gives you an interactive prompt for project-local files (with list selection! and install-now option!!);npm-check -u -g
does the same for global modules (including slap and, behold,npm
itself!!).