Manage node versions using NVM

Likely caused by the current verson of Node

First thing to try:

rails assets:clobber

Then delete the node_modules folder

rails assets:precompile

Check your node version

node -v

See which node versions are installed on this machine

Assuming you have nvm (node version manager) installed, this command will list your current node versions:

nvm ls

Switch node versions

nvm use 14

(zipmessage tends to work only with node version 14)

Installing nvm (node version manager)

If it's not installed on your machine yet, do this:

CD to the home directory:

cd ~/

Install nvm using homebrew:

brew install nvm

This creates the .nvm folder in your home folder briancasel

mkdir ~/.nvm

Then open .bash_profile and put this in it:

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

Then restart terminal

When you reopen it, you should be able to run nvm and see it's help documentation there.

nvm

Set a default version of node specific to each project directory

cd into the project directory and then set the node version you want to make default for this project:

nvm use 14

Then run this automatically create a .nvmrc file in this project directory containing the default node version:

node -v > .nvmrc

All .nvmrc does is make it so that when you run nvm use it will then load that version of node. It doesn't automatically load this version by default when you cd into this project.

To make it automatically load, I updated my alias for this project so that it both cd's to this project folder and then runs nvm use. To do this, I eded .bash_profile (located in home directory-briancasel) and then used this line to create my cdzm shortcut for zipmessage:

alias cdzm="cd ~/code/active/zipmessage; nvm use"

Then add .nvmrc to your .gitignore file so that it isn't pushed to github.

Last updated