dev.to
dev.to copied to clipboard
nestjs-passport-sessions blog no longer works
I was trying to follow along with your blog (and comments) but got stuck trying to initialize passport. I eventually decided to clone this repo and try your version to see what was different.
First, npm did not want to install due to conflicting dependencies
dev.to$ npm install npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: dev.to@undefined npm ERR! Found: @nestjs/[email protected] npm ERR! node_modules/@nestjs/common npm ERR! dev @nestjs/common@"^8.0.6" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @nestjs/common@"^7.x" from @golevelup/[email protected] npm ERR! node_modules/@golevelup/nestjs-modules npm ERR! dev @golevelup/nestjs-modules@"^0.4.2" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! the full error report is below
npm resolution error report
2022-03-30T16:47:32.656Z
While resolving: dev.to@undefined Found: @nestjs/[email protected] node_modules/@nestjs/common dev @nestjs/common@"^8.0.6" from the root project
Could not resolve dependency: peer @nestjs/common@"^7.x" from @golevelup/[email protected] node_modules/@golevelup/nestjs-modules dev @golevelup/nestjs-modules@"^0.4.2" from the root project
Fix the upstream dependency conflict, or retry this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.
Raw JSON explanation object:
{ "code": "ERESOLVE", "current": { "name": "@nestjs/common", "version": "8.4.3", "whileInstalling": { "name": "dev.to", "path": "/home/.../dev.to" }, "location": "node_modules/@nestjs/common", "isWorkspace": false, "dependents": [ { "type": "dev", "name": "@nestjs/common", "spec": "^8.0.6", "from": { "location": "/home/.../dev.to" } } ] }, "currentEdge": { "type": "dev", "name": "@nestjs/common", "spec": "^8.0.6", "from": { "location": "/home/.../dev.to" } }, "edge": { "type": "peer", "name": "@nestjs/common", "spec": "^7.x", "error": "INVALID", "from": { "name": "@golevelup/nestjs-modules", "version": "0.4.4", "whileInstalling": { "name": "dev.to", "path": "/home/.../dev.to" }, "location": "node_modules/@golevelup/nestjs-modules", "isWorkspace": false, "dependents": [ { "type": "dev", "name": "@golevelup/nestjs-modules", "spec": "^0.4.2", "from": { "location": "/home/.../dev.to" } } ] } }, "strictPeerDeps": false, "force": false } So, I used npm install --force to get past that
When I tried to launch the app, I got a very similar error to the one which was blocking my own implementation
dev.to/blog-posts/nestjs-passport-sessions$ npx nest start [Nest] 267343 - 03/30/2022, 9:39:02 AM LOG [NestFactory] Starting Nest application... [Nest] 267343 - 03/30/2022, 9:39:03 AM LOG [InstanceLoader] PassportModule dependencies initialized +838ms [Nest] 267343 - 03/30/2022, 9:39:03 AM LOG [InstanceLoader] RedisModule dependencies initialized +0ms [Nest] 267343 - 03/30/2022, 9:39:03 AM LOG [InstanceLoader] AppModule dependencies initialized +2ms [Nest] 267343 - 03/30/2022, 9:39:03 AM LOG [InstanceLoader] AuthModule dependencies initialized +0ms
/home/.../dev.to/node_modules/passport/lib/authenticator.js:133
return this._framework.initialize(this, options);
^
TypeError: Cannot read properties of undefined (reading 'initialize')
at Authenticator.initialize (/home/.../dev.to/node_modules/passport/lib/authenticator.js:133:26)
at AppModule.configure (/home/.../dev.to/blog-posts/nestjs-passport-sessions/dist/app.module.js:41:39)
at MiddlewareModule.loadConfiguration (/home/.../dev.to/node_modules/@nestjs/core/middleware/middleware-module.js:49:24)
at loadMiddlewareConfiguration (/home/.../dev.to/node_modules/@nestjs/core/middleware/middleware-module.js:38:24)
at Array.map (
Node.js Version: 16.13.2 Node Redis Version: 3.1.2 Platform: Ubuntu 20.04.4