1. how I upgraded the nodejs version to the latest LTS (I think) version
  2. (source: https://askubuntu.com/a/1291854) I executed the following commands (May 2022):

    sudo apt update
    curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
    sudo apt install -y nodejs
    node -v

    After running the last command I saw:

    $ node -v
    v14.19.2
    

    However, due to what I am almost confident are broken dependencies issues among my packages, the installation of node messed up my npm and I was unable to re-install it with conventional means. As such, I had to download the node tarball from here, explode the tarball in a directory and set in my PATH the path to node-v14.16.0-linux-x64/bin (wherein the npm executable is to be found). This was mighty iffy and unsettling.

  3. upgrade all dependencies to their latest major version
  4. source
    npm install -g npm-check-updates
    ncu -u
    npm update     # use this if node_modules already exists
    npm install    # use this otherwise
          
  5. how to monitor for code changes and to continuously run Node application
  6. I've used the nodemon package for that. See target monitor in package.json in my ora2pg migration assessment github project

  7. how to upgrade all package.json packages to the latest version
  8. I tried this to update to the latest major version and it worked like a charm.

  9. how to do npm installs without employing a cache
  10. By combining this SO answer with that SO answer, one can arrive at the following solution:

    export npm_config_cache=$(shell mktemp -d)
    
    install:
        @printf "using throw-away cache at: [$$npm_config_cache]\n"
        npm install
        @du -h $$npm_config_cache | printf "size of temp cache is: $$(du -h . | tail -1 | cut -f1)\n"
        @rm -fr $$npm_config_cache
        @printf "temporary cache at: $$npm_config_cache is now deleted.\n"
    
    clean:
        rm -fr node_modules/
        rm -f es5/*.js
        rm -f es5/*.map
        npm cache -f clean # this is not really necessary as we're using a throw-away cache 

  11. invoke an npm target without triggering the pre- and post- hooks:  npm run foo --ignore-scripts
  12. … or in the case of built-in targets like publish simply do:
    npm publish --ignore-scripts
    
  13. install Node 4.5 LTS on Ubuntu 14.04 Trusty Tahr
  14. install the latest version of node (assuming you have npm installed)
  15. downgrade from NPM3 to NPM2
  16. configure Mocha in Node.js with ECMAScript 2016
  17. publish a module to npm
  18. instruct Node to search for packages in the "local-global" location
  19. Put the following in your .bashrc:
        export NODE_PATH=$NODE_PATH:~/.node_modules_global/lib/node_modules
          
  20. Include a JavaScript file in the "traditional" sense
  21. source
    Notes:
    var fs = require('fs');
    // file is included here:
    eval(fs.readFileSync('file-to-include.js')+'');
          
    $ node
    > fs = require('fs');
    > fs.writeFileSync('fs.js', fs.toString())
    > fs.writeFileSync('fs.readFileSync.js', fs.readFileSync.toString())
    [Ctrl-C][Ctrl-C]
    
  22. How to install npm 3 in Ubuntu
  23. The following has worked for me in Ubuntu 14.04 and 12.04:
    sudo npm install npm@3 -g
    $ npm -version
    3.8.0
          
  24. How to install Node.js 4 in Ubuntu
  25. source
    The following process worked for me on Ubuntu 14.04 and 12.04 and allowed me to install Node.js v4.3.2:
    In a sudo shell:
    apt-key adv --keyserver keyserver.ubuntu.com --recv 68576280
    apt-add-repository 'deb https://deb.nodesource.com/node_4.x precise main'
    apt-get update
    apt-get install nodejs
          

    NB:I also have node symlinked via "alternatives" to nodejs:
    $ ls /usr/bin/node
    lrwxrwxrwx 1 root root 22 Mar  7 10:23 /usr/bin/node -> /etc/alternatives/node*
    $ ls /etc/alternatives/node
    lrwxrwxrwx 1 root root 15 Mar  7 10:23 /etc/alternatives/node -> /usr/bin/nodejs*
          
  26. How to install guard-livereload
  27. On 2016-02-20 the following procedure (source) worked for me:
    1. sudo apt-get install ruby-dev
    2. sudo gem install rdoc -V
    3. sudo gem install guard -V
    4. sudo gem install guard-livereload -V

    I think actually step 4 was the only necessary step.
    I then created the symlinks mentioned in this post below.
  28. How to install guard-livereload
  29. What worked for me (in 2015-10) was to follow the instructions from:

    the github repo for guard-livereload

    I've also created a script to run guard (in ~/playground/repo-wide-scripts).
    I the same location I've also created: Basically what needs now be done (in a new project, new machine) is:
    1. sudo gem install guard-livereload
    2. sudo apt-get install bundler
    3. ln -s ~/playground/repo-wide-scripts/Gemfile
    4. ln -s ~/playground/repo-wide-scripts/Guardfile
    5. ln -s ~/playground/repo-wide-scripts/run-guard

    An example of this properly setup and working well is found in my bouncing ball project (file run-guard which ultimately links to this script).
  30. how to install npm and configure it to install global packages in your home directory
  31. This is a great guide in how to setup npm for your local environment (and how to configure global to point to your home directory instead).
    I've made a copy of the document in case the original resource goes offline here
  32. NB: Deprecated How to use node and install npm packages in home folder
  33. I have used the approach to install node packages via the npm tool in the home folder as described here. However with this approach, one (at least in Ubuntu 14.04) cannot use the nodejs executable but has to use the node one that is available with the nvm tool. This is described here in the section "How to Install Using NVM". NB:I actually had to use sudo curl .. | sh to install it.

    Then don't forget upon installing a package, e.g. npm prompt to also do nvm link prompt (as described in the link above). An example is given in:
            ~/playground/javascript-you-dont-know
          
  34. NB: Deprecated (?) install Node.js for Ubuntu
  35. On 6.II.2015 I followed these instructions and they worked on my Ubuntu 12.04 machine.