jmcdo29 / jmcdo29/dev.to

nestjs-passport-sessions blog no longer works

Open
#5 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16
Forks
17
PR merge metrics
No merged PRs in 30d

Description

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/common@8.4.3
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/nestjs-modules@0.4.4
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/common@8.4.3
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/nestjs-modules@0.4.4
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 ()
at MiddlewareModule.resolveMiddleware (/home/.../dev.to/node_modules/@nestjs/core/middleware/middleware-module.js:41:41)
at MiddlewareModule.register (/home/.../dev.to/node_modules/@nestjs/core/middleware/middleware-module.js:33:20)
at NestApplication.registerModules (/home/.../dev.to/node_modules/@nestjs/core/nest-application.js:80:37)
at NestApplication.init (/home/.../dev.to/node_modules/@nestjs/core/nest-application.js:94:20)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Environment:

Node.js Version: 16.13.2
Node Redis Version: 3.1.2
Platform: Ubuntu 20.04.4

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.