Algorithm should be set - node.js

I'm working on a Cypress project that was working fine.
But recently, it started throwing some errors. I searched for reasons as to why I was getting the errors. I found out that in my index.js file the export.module had a line to throw an error if the option algorithm was not set as below.
My question is where should I set the said algorithms and how?
Here's the git repository of the project
https://github.com/Leealp/BugsFixed2
module.exports = function(options) {
....................................................................
if (!options.algorithms) throw new Error('algorithms should be set');
var secretCallback = options.secret;
if (!isFunction(secretCallback)){
secretCallback = wrapStaticSecretInCallback(secretCallback);
}
....................
....................
}
The error is below:
C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)\node_modules\express-jwt\lib\index.js:22
if (!options.algorithms) throw new Error('algorithms should be set');
^
Error: algorithms should be set
at module.exports (C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)\node_modules\express-jwt\lib\index.js:22:34)
at Object.<anonymous> (C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)\auth.js:20:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)\api\users.js:3:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)\api\index.js:8:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)\app.js:17:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
PS C:\Users\AlphaLy\Documents\Coding\Cypress Web Automation upload\CypressLastPractices\node-express-sequelize-nextjs(L)>

Related

GLIBC_2.25 not found when tyring using argon2 in nodejs

this is the response i got when i run node file
`node:internal/modules/cjs/loader:1210
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /lib64/libc.so.6: version GLIBC_2.25' not found (required by /home/mhmd8/nodevenv/dad.online/16/lib/node_modules/argon2/lib/binding/napi-v3/argon2.node) at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18) at Module.load (node:internal/modules/cjs/loader:1004:32) at Function.Module._load (node:internal/modules/cjs/loader:839:12) at Module.require (node:internal/modules/cjs/loader:1028:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (/home/muhamad8/nodevenv/resumeku.online/16/lib/node_modules/argon2/argon2.js:9:25) at Module._compile (node:internal/modules/cjs/loader:1126:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) at Module.load (node:internal/modules/cjs/loader:1004:32) at Function.Module._load (node:internal/modules/cjs/loader:839:12) { code: 'ERR_DLOPEN_FAILED' }
how i can solve this problem, thanks!

Npm not installing after updating and getting TypeError

when I check the node version and npm version in my nodejs terminal everything appears to be working fine. When I try doing something in VS code and run the, "npm -v", I get all this stuff below. I tried opening the folder via powershell and running npm -v but get the same stuff.
Node version is showing: v16.17.0
C:\Program Files\nodejs\node_modules\npm\node_modules\socks-proxy-agent\dist\index.js:110
class SocksProxyAgent extends agent_base_1.Agent {
^
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\socks-proxy-agent\dist\index.js:110:44)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\lib\agent.js:174:29)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\lib\remote.js:7:18)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
C:\Program Files\nodejs\node_modules\npm\node_modules\socks-proxy-agent\dist\index.js:110
class SocksProxyAgent extends agent_base_1.Agent {
^
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\socks-proxy-agent\dist\index.js:110:44)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\lib\agent.js:174:29)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\make-fetch-happen\lib\remote.js:7:18)
at Module._compile (node:internal/modules/cjs/loader:1126:14)

I am getting the error, Can not find the module './--require.js' using mocha

I am trying to write the unit test case using mocha and chai but I am getting the error:-Cannot find module './--require.js when I run the test case.
the script is:- "test": "mocha --require babel-core/register 'server/api/**/*.test.js'"
full error:-
D:\gitlab-to-azure\blik-app\node_modules\yargs\yargs.js:1163
else throw err
^
Error: Cannot find module './--require.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.getConstants (D:/gitlab-to-azure/blik-app/server/config/environment/index.js:12:16)
at Object.<anonymous> (D:/gitlab-to-azure/blik-app/server/app.js:20:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at loader (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (D:/gitlab-to-azure/blik-app/server/api/group/group.test.js:2:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at loader (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (D:\gitlab-to-azure\blik-app\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\mocha.js:334:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\mocha.js:331:14)
at Mocha.run (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\mocha.js:809:10)
at Object.exports.singleRun (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\run-helpers.js:108:16)
at exports.runMocha (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\run-helpers.js:142:13)
at Object.exports.handler.argv [as handler] (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\run.js:292:3)
at Object.runCommand (D:\gitlab-to-azure\blik-app\node_modules\yargs\lib\command.js:242:26)
at Object.parseArgs [as _parseArgs] (D:\gitlab-to-azure\blik-app\node_modules\yargs\yargs.js:1087:28)
at Object.parse (D:\gitlab-to-azure\blik-app\node_modules\yargs\yargs.js:566:25)
at Object.exports.main (D:\gitlab-to-azure\blik-app\node_modules\mocha\lib\cli\cli.js:68:6)
at Object.<anonymous> (D:\gitlab-to-azure\blik-app\node_modules\mocha\bin\mocha:164:29)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)```
Folder Structure:-
server
api
groups
controller.js
model.js
groups.test.js
You would need to qualify for the full path for the mocha runner, you can try something like this
"test": "./node_modules/.bin/mocha --compilers js:#babel/register 'server/api/**/*.test.js'"

Node App - ReferenceError: uriUtil is not defined

I was workign on a Node App a few weeks ago which worked fine. I went to restart it today and its throwing this error
var mongooseUri = uriUtil.formatMongoose(mongodbUri);
^
ReferenceError: uriUtil is not defined
at Object.<anonymous> (d:\A\B\C\Web Applications\Donations1\routes\donations.js:14:19)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (d:\A\B\C\Web Applications\Donations1\app.js:9:17)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:139:18)
at node.js:999:3
It relates to this line of code that connects to mongodb
var mongodbUri = 'mongodb://AAA:BBB#ds053305.mongolab.com:12345/donations';
var mongooseUri = uriUtil.formatMongoose(mongodbUri);
You can replace this line:
var mongooseUri = uriUtil.formatMongoose(mongodbUri);
Which this line:
var mongooseUri =require('mongodb-uri').formatMongoose(mongodbUri);
Don't worry to require same module more than once. Node always require only one time, and after that use the cache for loading the module.

Getting type error with Sequelizejs

Im getting the following error and I can't figure out through the stack trace where it's erroring.
/Users/rahulsharma/Desktop/Jobletics/node_modules/sequelize/lib/sequelize.js:298
this.importCache[path] = defineCall(this, DataTypes)
^
TypeError: object is not a function
at module.exports.Sequelize.import (/Users/ra/Desktop/Js/node_modules/sequelize/lib/sequelize.js:298:32)
at db.sequelize (/Users/ra/Desktop/Js/models/index.js:14:33)
at Array.forEach (native)
at Object.<anonymous> (/Users/ra/Desktop/Js/models/index.js:13:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
Here is the git:
https://github.com/rahul1346/jb
Any idea?
business_model.js is an empty file.

Resources