Node.js: Difference between revisions

From Bitpost wiki
Line 27: Line 27:
* After installing a new node version with [nvm install --lts], you'll have to reinstall all node packages:
* 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
  cdr && npm install -g; cdm && npm install -g; cdas && npm install -g
* Reinstallation problems
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].
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].
I have also had problems with file locking and permissions when tools like Visual Studio Code are running.
    fixes:
        x close visual studio and kill all node exes (this didn't help this time but has in the past i think?)
        * remove the globally-officially-installed rad-scripts as it blocks installation from the local repo
            rm -rf /home/m/.nvm/versions/node/v8.12.0/lib/node_modules/rad-scripts
            Apparently, we should always use npm install -g from [cdr], not [npm install -g rad-scripts]
            F'in npm.  cmon up your game before yarn etc fragments things into oblivion...


* 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.
* 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.

Revision as of 19:06, 14 October 2018

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
  • Reinstallation problems

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].

I have also had problems with file locking and permissions when tools like Visual Studio Code are running.

   fixes:
       x close visual studio and kill all node exes (this didn't help this time but has in the past i think?)
       * remove the globally-officially-installed rad-scripts as it blocks installation from the local repo
           rm -rf /home/m/.nvm/versions/node/v8.12.0/lib/node_modules/rad-scripts
           Apparently, we should always use npm install -g from [cdr], not [npm install -g rad-scripts]
           F'in npm.  cmon up your game before yarn etc fragments things into oblivion...
  • 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.