Having a bit of a hard time to upgrade the project from V? to V7

Hello there!

As I am getting this yellow top banner telling my project will soon (june 30th) stop working (depreciated), I got into the upgrade of it :slight_smile:

As stated in a previous post, I translated a part of my project into Typescript and everything was working well. However, updating my work to v7 has been a tough job and so, I decided to update Lumber (I had a version from 2019 installed on my machine) to the latest release and create a fresh new project (in order to generate brand new sources)

I started to import all my code. Of course I had to rewrite some (mostly models approach) but otherwise, it was mostly overriding existing code (app.js, server.js, middlewares/*, etc)

Expected behavior

When I start my program, i would like it to work xD

Actual behavior

I am getting something quite weird which seems to be related to jwt

[11:57:03 PM] Starting compilation in watch mode...

[11:57:22 PM] Found 0 errors. Watching for file changes.

[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): dist\**\*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./dist/server.js`
  if (!options.algorithms) throw new Error('algorithms should be set');

Error: algorithms should be set
    at module.exports (C:\.........\project\node_modules\express-jwt\lib\index.js:22:34)
    at Object.<anonymous> (C:\.........\project\dist\app.js:31:9)


Please provide any relevant information about your setup.

"dependencies": {
  "@types/express": "^4.17.11",
  "@types/forest-express-mongoose": "^7.5.0",
  "@types/mongoose": "^5.10.5",
  "axios": "^0.21.1",
  "body-parser": "1.19.0",
  "chalk": "~4.1.1",
  "cookie-parser": "1.4.5",
  "cors": "2.8.5",
  "debug": "~4.3.1",
  "dotenv": "~9.0.2",
  "express": "~4.17.1",
  "express-jwt": "6.0.0",
  "forest-express-mongoose": "^7.6.0",
  "mongoose": "~5.12.9",
  "morgan": "1.10.0",
  "nodemon": "^2.0.7",
  "require-all": "^3.0.0",
  "tsc-watch": "^4.2.9",
  "typescript": "^4.2.4"

Maybe it’s all about giving an algorithm parameter to jwt at initialisation but I don’t even know which one to put so…

Let me know if you need more info :slight_smile:




Hello @Emixam23,

It seems that you also updated the dependency express-jwt in the process. I just generate a new project with lumber locally to check, and the version that is generated is "express-jwt": "5.3.1", but your package.json file shows that you are requiring "express-jwt": "6.0.0".

This new version requires you to specify an algorithm for the JWT, as stated in their docs.

In your case, you can add algorithms: ['HS256'] in the file app.json:

  secret: process.env.FOREST_AUTH_SECRET,
  credentialsRequired: false,
  algorithms: ['HS256']

Or downgrade express-jwt to the latest v5

Thanks :slight_smile:

I could mostly move forward, I recreated a side project and then adapt mine to it :slight_smile:

I still have some issue but I guess it’s more related to mongoose/typescript, so I am gonna open a new issue as it’s related to one part of your documentation which might be a bit obsolete :slight_smile:

New issue at: Upgrading to v7, MongoDB/Typescript documentation might be a bit obsolete

Thanks for your help!