Testing Inversify w/ Mocha causes strange error ERROR_MSGS.NULL_ARGUMENT - node.js

I'm getting the following error when I try to test my code with Mocha/Chai.
Has anyone else seen this error?
/Users/me/Sites/my_project/node_modules/inversify/lib/container/lookup.js:13
throw new Error(ERROR_MSGS.NULL_ARGUMENT);
^
Error: NULL argument
at Lookup.add (/Users/me/Sites/my_project/node_modules/inversify/lib/container/lookup.js:13:19)
at Container.bind (/Users/me/Sites/my_project/node_modules/inversify/lib/container/container.js:121:33)
at Object. (/Users/me/Sites/my_project/test/api-temp/dependency-injection.js:9:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/me/Sites/my_project/test/api-temp/services/some.service.js:21:32)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/me/Sites/my_project/test/api-temp/services/some.service.spec.js:4:24)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /Users/me/Sites/my_project/node_modules/mocha/lib/mocha.js:222:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/me/Sites/my_project/node_modules/mocha/lib/mocha.js:219:14)
at Mocha.run (/Users/me/Sites/my_project/node_modules/mocha/lib/mocha.js:487:10)
at Object. (/Users/me/Sites/facecards-api/node_modules/mocha/bin/_mocha:459:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
npm ERR! Darwin 16.5.0
npm ERR! argv "/Users/me/.nvm/v4.4.5/bin/node" "/Users/dan/.nvm/v4.4.5/bin/npm" "run" "test-api" "-w"
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! my_project#1.0.0 test-api: `mocha -R spec './test/api-temp/**/*.spec.js' --reporter min --inline-diffs`
npm ERR! Exit status 1
The problem occurs when I try to new up the class in my test code.
describe('SomeService', () => {
let someService: any
someService = new SomeService(null, null, null)
mockFunction = sinon.createStubInstance(someService, 'function')
describe('#function', () => {
beforeEach(() => {
result = someService.function(1234)
})
it('should call function', () => {
expect(.callCount).to.eql(1)
})
})
})

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?

Getting Error while using razorpay in file

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)

Syntax error on express app.use

I have used this code with my node.js application with express but when uploading to Heroku I get an error when running.
2016-09-28T11:01:40.502448+00:00 app[web.1]: /app/routes/index.js:146
2016-09-28T11:01:40.502467+00:00 app[web.1]: app.use(({method, url}, rsp, next) => {
2016-09-28T11:01:40.502468+00:00 app[web.1]: ^
2016-09-28T11:01:40.502468+00:00 app[web.1]:
2016-09-28T11:01:40.502469+00:00 app[web.1]: SyntaxError: Unexpected token {
2016-09-28T11:01:40.502469+00:00 app[web.1]: at exports.runInThisContext (vm.js:53:16)
2016-09-28T11:01:40.502470+00:00 app[web.1]: at Module._compile (module.js:387:25)
2016-09-28T11:01:40.502471+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
2016-09-28T11:01:40.502471+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-09-28T11:01:40.502472+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-09-28T11:01:40.502473+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-09-28T11:01:40.502473+00:00 app[web.1]: at require (internal/module.js:20:19)
2016-09-28T11:01:40.502474+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:8:14)
2016-09-28T11:01:40.502474+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-09-28T11:01:40.502475+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
My code is
app.use(({method, url}, rsp, next) => {
rsp.on('finish', () => {
console.log(`${rsp.statusCode} ${method} ${url}`);
});
next();
});
Any help would be much appreciated
In your package.json, do you specify the node engine?
"engines": {
"node": "6.5.0"
}
I would have just added this as a comment, but I don't have enough rep.

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