Node.js

From Bitpost wiki
Revision as of 20:31, 14 September 2018 by M (talk | contribs) (→‎Troubleshoot)

Installation

Windows

Linux

export NVM_DIR="/home/m/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
  • nvm ls-remote --lts
  • nvm install --lts # to get the latest long-term-support release - you can pick a release too if needed, eg 5.8.0)
  • nvm ls # show what you have
  • nvm alias default stable # needed?
  • the common .bashrc_env should take care of node setup
  • additional fyi goo
    • nvm use 4.2.1; node -v; nvm ls; nvm alias default 0.11.13; nvm use default
    • You can create an .nvmrc file containing version number in the project root directory and it will default to that version
    • Global package install example: npm install -g rad-scripts

Upgrade

Don't mess with anything other than lts, you've been warned:

  • nvm install --lts

Troubleshoot

  • After installing a new node version with [nvm install --lts], you'll have to reinstall all node packages:
cdr && npm install -g; cdm && npm install -g; cdas && npm install -g

Warning: I had trouble when globally installing rad-scripts from npm and from my local source; for now I'll avoid [npm install -g rad-scripts].

  • If filesystem navigation is slow, loadning npm can be EXTREMELY slow; you can add [ --no-use] to startup, then call [node use] before using it, as a shitty workaround. I'll keep upgrading npm until it is sane. It sure has had a rough growing journey.