Build a Secure NestJS API with Postgres
Learn to build a secure Node.js API using NestJS, TypeScript, and Postgres!
Build a Secure NestJS API with Postgres
Learn to build a secure Node.js API using NestJS, TypeScript, and Postgres!
Adriang
running npx nodemon server.js --ext ts
throws the following error, primordials is not defined
. I’m running node 12.x. Anyone know what is the fix for this?
David Neal
@@disqus_812yAN1WP3 I stepped through the instructions up to running the npx
command, and I’m not seeing the same error. I’m running Node.js 12.6.1 on macOS. A quick search points to gulp or graceful-fs as the culprit for this error, but I don’t see either of those as a dependency for any of modules required to run this project. If you delete your node_modules folder, run npm install
and then npm start
, do you get the same error?
Adriang
Thanks for getting back to me. I’ve deleted and reinstalled the node_modules. Running npm start
works fine. I’m able to get Swagger in the browser. But npx nodemon server.js --ext ts
still throws that error.
David Neal
That is really bizarre. I see that nodemon uses graceful-fs
as a dependency, so that must be what is causing the error. However, the latest version of nodemon should work without error. Maybe an older version of nodemon is cached on your system?
Try this for a workaround. Install nodemon as a developer dependency in the project using npm install --save-dev nodemon@2
. Add an npm script to your package.json file that looks like this:
“scripts”: {
“dev”: “nodemon server.js --ext ts”
},
Now you should be able to do the same thing the npx command was doing by running npm run dev
at the command line.
Adriang
That worked. Thx
Adriang
I’m getting the follow error:okta-nestjs-postgres-example/node_modules/@okta/okta-auth-js/lib/errors/AuthSdkError.js:26
AuthSdkError.prototype = new Error();
Alex
Hi! Does server send request to OKTA client with method oktaClient.getSession(sessionId)
on each user’s request? Or server should cache this session? What is right way?
Justin Dearing
In okta-client.ts you need to add https:// to the oktaAuthClient() constructor paramater around line 15. e.g:
const issuer =https://${OKTA_DOMAIN}/oauth2/default
;
console.debug(‘Loaded oktaClient’);
const oktaAuthClient = new OktaAuth({
issuer: issuer,
});
I just wrote a similar article about setting up Okta Authentication with Nest.js and Authorising users based on role permissions.