Getting Error while using razorpay in file - node.js

Whenever I do
const Razorpay = require('razorpay');
There's an error coming up in node_modules/razorpay during running the server
node_modules\request-promise-core\configure\request2.js:34
var originalInit = options.request.Request.prototype.init;
^
TypeError: Cannot read property 'prototype' of undefined
at module.exports (node_modules\request-promise-core\configure\request2.js:34:48)
at Object. (node_modules\request-promise\lib\rp.js:28:1)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (node_modules\razorpay\dist\api.js:7:15)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (node_modules\razorpay\dist\razorpay.js:7:11)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)

Related

I found this error while compiling the solidity code

node:internal/modules/cjs/loader:959
throw err;
^
Error: Cannot find module 'ethers'
Require stack:
D:\Blockchain\deploy.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (D:\Blockchain\deploy.js:1:16)
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 Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'D:\Blockchain\deploy.js' ]
}
can anyone help me to find the solution to this error?

Mongoose Error must pass in valid bson parser

So I have a docker container (running a testing suite environment) that has stopped work on me. I'm using Mongoose 4.13.17. The problem I'm running into is every time I try to run my test cases it tries to connect to a testing db container but I get this error message.
Error: must pass in valid bson parser
at new Pool (/srv/app/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:105:13)
at Server.connect (/srv/app/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:373:17)
at Server.connect (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/server.js:368:17)
at open (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/db.js:229:19)
at Db.open (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/db.js:252:44)
at createServer (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js:391:6)
at /srv/app/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js:512:14
at parseHandler (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:117:38)
at module.exports (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:97:5)
at connect (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js:485:3)
at Function.MongoClient.connect (/srv/app/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js:250:3)
at /srv/app/node_modules/mongoose/lib/connection.js:820:25
at Promise._execute (/srv/app/node_modules/bluebird/js/release/debuggability.js:313:9)
at Promise._resolveFromExecutor (/srv/app/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/srv/app/node_modules/bluebird/js/release/promise.js:79:10)
at NativeConnection.Connection.openUri (/srv/app/node_modules/mongoose/lib/connection.js:819:17)
at Mongoose.connect (/srv/app/node_modules/mongoose/lib/index.js:262:17)
at new App (/srv/app/src/app.ts:34:5)
at Object.<anonymous> (/srv/app/src/app.ts:80:16)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Module.replacementCompile (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:58:13)
at Module.m._compile (/srv/app/node_modules/ts-node/src/index.ts:439:23)
at module.exports (/srv/app/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
at /srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4
at require.extensions.(anonymous function) (/srv/app/node_modules/ts-node/src/index.ts:442:12)
at Object.<anonymous> (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/srv/app/src/server.ts:6:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Module.replacementCompile (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:58:13)
at Module.m._compile (/srv/app/node_modules/ts-node/src/index.ts:439:23)
at module.exports (/srv/app/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
at /srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4
at require.extensions.(anonymous function) (/srv/app/node_modules/ts-node/src/index.ts:442:12)
at Object.<anonymous> (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/srv/app/test/unit/rest/Audio.test.ts:3:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Module.replacementCompile (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:58:13)
at Module.m._compile (/srv/app/node_modules/ts-node/src/index.ts:439:23)
at module.exports (/srv/app/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
at /srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4
at require.extensions.(anonymous function) (/srv/app/node_modules/ts-node/src/index.ts:442:12)
at Object.<anonymous> (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /srv/app/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/srv/app/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/srv/app/node_modules/mocha/lib/mocha.js:576:10)
at Object.<anonymous> (/srv/app/node_modules/mocha/bin/_mocha:637:18)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Module.replacementCompile (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:58:13)
at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Object.<anonymous> (/srv/app/node_modules/nyc/node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at runMain (/root/.node-spawn-wrap-45-4803909aaae7/node:68:10)
at Function.<anonymous> (/root/.node-spawn-wrap-45-4803909aaae7/node:171:5)
at Object.<anonymous> (/srv/app/node_modules/nyc/bin/wrap.js:23:4)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at /root/.node-spawn-wrap-45-4803909aaae7/node:178:8
at Object.<anonymous> (/root/.node-spawn-wrap-45-4803909aaae7/node:181:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:279:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
I've looked all around for a solution but it doesn't seem like this is an extremely common problem.
This is what my class looks like:
import * as bluebird from 'bluebird';
import { Application } from 'express';
import { connect, connection, disconnect, mongo } from 'mongoose';
import * as mongoose from 'mongoose';
import 'reflect-metadata'; // this shim is required for routing-controllers
import { createExpressServer, useContainer } from 'routing-controllers';
import { Container } from 'typedi';
import { getEnv } from './Service/Env';
// middleware
import { AuthenticateTokenMiddleware } from './Middleware/AuthenticateTokenMiddleware';
import { CorsHeadersMiddleware } from './Middleware/CorsHeadersMiddleware';
import { DisableAllExceptGetMiddleware } from './Middleware/DisableAllExceptGetMiddleware';
import { ParseTokenMiddleware } from './Middleware/ParseTokenMiddleware';
// controllers
import { init } from 'ooyala-express';
import { AudioController } from './Controller/V1/AudioController';
import { MovieController } from './Controller/V1/MovieController';
import { RootController } from './Controller/V1/RootController';
import { Indexer } from './indexer';
class App {
public express: Application;
constructor() {
(<any> mongoose).Promise = bluebird;
connect(getEnv('MONGODB_URI'), { useMongoClient: true });
useContainer(Container);
Indexer.ensureIndexes();
init({
ooyala_api_host: getEnv('ooyala_api_host'),
ooyala_cdn_host: getEnv('ooyala_cdn_host'),
ooyala_rights_locker_host: getEnv('ooyala_rights_locker_host'),
ooyala_player_host: getEnv('ooyala_player_host'),
player_expiration_window: getEnv('player_expiration_window'),
});
this.express = createExpressServer({
// Disable so we don't get a nasty serialized mongoose document.
// If they fix the issue with Expose/Exclude not being respected then
// perhaps this could be set back to true
classTransformer: false,
controllers: [
RootController,
AudioController,
MovieController,
],
middlewares: [
// Order is important. Middlewares are executed in index order.
CorsHeadersMiddleware,
DisableAllExceptGetMiddleware,
ParseTokenMiddleware,
AuthenticateTokenMiddleware,
],
});
}
}
export default new App().express;

moongoose js Schema is not a Constructor and function error

I am facing a problem with moongoose js
This is my node js code:
var mongoose=require('moongoose');
var test=mongoose.Schema({test:String})
module.exports = mongoose.model('test',test);
When I run this code, node js throws:
var test=mongoose.Schema({test:String})
^
TypeError: **mongoose.Schema is not a function**
at Object.<anonymous> (H:\TodoList\Model\TodoListModel.js:4:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (H:\TodoList\app.js:9:10)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
If I change this code to this format:
var mongoose=require('moongoose');
var Schema = mongoose.Schema;
var test=new Schema({test:String})
module.exports = mongoose.model('test',test);
That code throws:
TypeError: **Schema is not a constructor**
Please help me to resolve this code error.
Its require('mongoose'); you have written require('moongoose');
an o typo :))

Error while running js file via node

I was trying to run my koa app.js file but I could not get it to work.
Here's my app.js
var koa = require('koa'),
monk = require('monk'),
wrap = require('co-monk');
var db = monk("mongodb url here"),
collection = db.get('mycollection'),
transactions = wrap(collection);
var app = koa();
app.use(function*(){
var res = yield transactions.find({});
console.log(res);
});
app.listen(3000);
and here's the error i got:
TypeError: Cannot read property 'name' of undefined
at makeSkinClass (/home/ric/node_modules/mongoskin/lib/utils.js:33:43)
at Object.<anonymous> (/home/ric/node_modules/mongoskin/lib/grid.js:6:35)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/ric/node_modules/mongoskin/lib/db.js:22:16)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/ric/node_modules/mongoskin/lib/mongo_client.js:5:14)
I'm still new to Koa,nodejs so I'm having a hard time figuring this out. Any help would be great!

Error in running balloons.io app?

When I run my balloons.js (https://github.com/gravityonmars/Balloons.IO) it shows this error:
url.js:118
throw new TypeError("Parameter 'url' must be a string, not " + typeof url)
^
TypeError: Parameter 'url' must be a string, not undefined
at Url.parse (url.js:118:11)
at Object.urlParse [as parse] (url.js:112:5)
at Config (/home/user/Balloons.IO/config/index.js:56:25)
at Object.<anonymous> (/home/user/Balloons.IO/balloons.js:18:20)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
The above app uses Redis.

Resources