Installing a Javascript Stack

Now I want my javascript stack back - which means node and npm.

Get these by going to nodejs.org and downloading the stable version.

The next thing I want to do is install Tiddlywiki globally, which requires me to do “npm install -g tiddlywiki” which will throw errors, complaining that it doesn’t have the right permissions for the directory it needs to use.

I don’t know why this is the case, perhaps there is a good reason why it doesn’t have the right permissions by default, but it’s a well-understood and common problem and the possible solutions are here: https://docs.npmjs.com/getting-started/fixing-npm-permissions

The trouble with things like this when you’re first starting out is that you have no idea which solution will be the best in the long run. I think you’re better off going with nvm, rather than tinkering around with the permissions manually.

https://docs.npmjs.com/getting-started/fixing-npm-permissions

I may as well get nvm, which needs something from x-code, probably just from the command line tools, which you can install separately, but I know I want x-code anyway, so download the whole thing and install it. Run it once before getting nvm. The first time it runs, it will take a while to install components.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

Once x-code is installed, the curl command should work and we’ll see the message

Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

You can paste that whole command at the terminal.

If you look in .bash_profile, you’ll see the same stuff there.

hmmm… this doesn’t seem to solve the permissions problem (because I was still using the system version of node)

Before proceeding, run ‘nvm install node’ which will grab the latest version - which might be the same as the one we already got, but now it’s managed by nvm, handled within it’s hidden directory structure and it will manage permissions for us.

Now we can finally run npm install -g tiddlywiki the way we wanted to and it will work without any permission errors.

https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x

https://docs.npmjs.com/misc/removing-npm

https://docs.npmjs.com/cli/ls

$ npm ls -g –depth=0

https://gist.github.com/TonyMtz/d75101d9bdf764c890ef

NB: It is also possible to install this with Node Version Manager - that, apparently, will manage the permissions for us but I'm not sure what other complexities it might add.

cd /usr/local/lib

rm -rf /usr/local/lib/node_modules
cd /usr/local/include
 sudo rm -rf node
  519  brew uninstall node

  524  cd /usr
  525  ls
  526  cd local
  527  ls

  528  cd /Users/richardsmith/
  532  sudo rm .node-gyp
  533  sudo rm -rf .node-gyp
  534  sudo rm -rf .npm

  557  cd /usr/local
  561  mvdir bin oldbin
  562  mv bin oldbin
  563  sudo mv bin oldbin
  565  sudo mkdir bin

  570  cd /usr/local/share/man/man1
  578  sudo rm node.1

  579  cd /usr/local/lib/dtrace/
  581  sudo rm node.d

  596  node
  597  npm -v

---

UNINSTALLED

---
  
  601  npm install -g tiddlywiki
  602   npm config get prefix
  603  $(whoami)
  604   sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
  605  reset
  606  npm install -g tiddlywiki
  607  tiddlywiki --version
  
cd /usr/local/lib
  502  ls
  503  cd node_modules/
  504  ls
  505   rn *
  506  rm *
  507  rm -r *
  508  ls
  509  sudo rm -rf *
  510  ls
  511  cd ..
  512  ls
  513  rmdir node_modules/
  514  ls
  515  cd /usr/local/include
  516  ls
  517  sudo rm -rf node
  518  ls
  519  brew uninstall node
  520  node -v
  521  cd 
  522  ls
  523  pwd
  524  cd /usr
  525  ls
  526  cd local
  527  ls
  528  cd /Users
  529  ls
  530  cd richardsmith/
  531  ls
  532  sudo rm .node-gyp
  533  sudo rm -rf .node-gyp
  534  sudo rm -rf .npm
  535  node -v
  536  cd /isr/local/include
  537  cd /usr/local/include
  538  ls
  539  cd
  540  ls
  541  cd .local
  542  ls
  543  cd bin
  544  ls
  545  cd ../..
  546  ls
  547  cd Developer/
  548  ls
  549  cd ..
  550  ls
  551  cd Library/
  552  ls
  553  cd Developer/
  554  ls
  555  cd ../..
  556  ls
  557  cd /usr/local/bin
  558  ls
  559  cd ..
  560  ls
  561  mvdir bin oldbin
  562  mv bin oldbin
  563  sudo mv bin oldbin
  564  mkdir bin
  565  sudo mkdir bin
  566  ls
  567  node -v
  568  cd /use/local
  569  cd /user/local
  570  cd /usr/local
  571  ls
  572  cd share
  573  ls
  574  cd man
  575  ls
  576  cd man1
  577  ls
  578  sudo rm node.1
  579  cd /usr/local/lib/dtrace/
  580  ls
  581  sudo rm node.d
  582  ls
  583  cd /usr/local/bin/
  584  ls
  585  cd ..
  586  cd /usr/local/lib
  587  ls
  588  cd dtrace
  589  ls
  590  cd /opt/local/bin
  591  cd /opt/local
  592  cd /opt
  593  cd /Users
  594  cd richardsmith/
  595  ls
  596  node
  597  npm -v
  598  npm -v
  599  node -v
  600  reset
  601  npm install -g tiddlywiki
  602   npm config get prefix
  603  $(whoami)
  604   sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
  605  reset
  606  npm install -g tiddlywiki
  607  tiddlywiki --version
  608  npm install -g tiddlywiki
  609  ls
  610  pwd
  611  cd /usr/bin/local
  612  cd /usr
  613  ls
  614  cd bin
  615  ls
  616  cd usr/local
  617  cd usr
  618  cd /usr/local
  619  ls
  620  cd bin
  621  ls
  622  history

!!Fixing NPM Permissions

https://docs.npmjs.com/getting-started/fixing-npm-permissions

!!