Wishlist!

Having finished my C++ journey, it is time to get back to web apps! Incidentally I got the job, but didn’t take it. It was a dream job as far as what I would have been doing, but the pay was not enough. A shame that, but I do have bills to pay.

In order to get into the holiday spirit I threw together an app I have called Wishlist. It allows a group of folks to create holiday wish lists, and then claim gifts from others’ lists to keep two people from buying the same gift. Pretty fun huh? It came together pretty quickly thanks to all my efforts on the (still unfinished) Ledger, but I did pick up a couple of tips along the way.

The first occurred after I upgraded nvm for windows, which is a handy little application. After upgrading I noticed that there was a more recent minor version of npm available that hadn’t made it into nvm for windows yet. When I went to upgrade, the following happened:

PS C:\Users\*****\Documents> npm install -g npm@latest
npm notice
npm notice New minor version of npm available! 7.0.14 -> 7.1.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.1.0
npm notice Run npm install -g npm@7.1.0 to update!
npm notice
npm ERR! code EEXIST
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! EEXIST: file already exists
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

Oh no, what to do? I had to experiment a little bit with some of the various online suggestions to get this fixed. The first step was to rename the following files:

C:\Users\*****\AppData\Roaming\nvm\v15.3.0\npm => npm_old
C:\Users\*****\AppData\Roaming\nvm\v15.3.0\npm.cmd => npm_old.cmd

Then I issued the following command, and I found that using full paths here was important:

C:\Users\*****\AppData\Roaming\nvm\v15.3.0\node.exe C:\Users\*****\AppData\Roaming\nvm\v15.3.0\node_modules\npm\bin\npm-cli.js i -g npm@latest

Interestingly enough this “upgraded” npm to 6.14.9, which was a lower version than what nvm for windows had installed. But once this version was installed, I was able to execute npm install -g npm@7.1.0 and be on my way.

The second was to add a “catchall URL” to the django backend so that it wouldn’t conflict with the react routing on the front end. If this is absent, you will see a 404 error if you reload on a non-default route. This catchall URL goes at the end of the list, so that it won’t conflict with any of the django URLs:

from django.urls import path, re_path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
    # ... all the other paths specific to your app ...
    re_path(r'^(?:.*)/?$', views.index)
]

The Wishlist app is working pretty well so far, needs some minor touchups but I think next up is to finally finish the Ledger app!