1
votes

I am using MEAN.JS for developing a web app, but for some reason after I made few changes, well mostly copied and paste new modules into the app I see the error as below:

error: uncaughtException: require(...).invokeRolesPolicies is not a function

I dont know why is this happening, anyone has any clue how to fix this?

This is the whole error message:

TypeError: require(...).invokeRolesPolicies is not a function at C:\oferdo\oferdo\config\lib\express.js:180:39 at Array.forEach (native) at Object.module.exports.initModulesServerPolicies (C:\oferdo\oferdo\config\lib\express.js:179:32) at Object.module.exports.init (C:\oferdo\oferdo\config\lib\express.js:252:8) at C:\oferdo\oferdo\config\lib\app.js:29:23 at C:\oferdo\oferdo\config\lib\mongoose.js:36:15 at C:\oferdo\oferdo\node_modules\mongoose\lib\connection.js:284:19 at open (C:\oferdo\oferdo\node_modules\mongoose\lib\connection.js:511:17) at C:\oferdo\oferdo\node_modules\mongoose\lib\connection.js:518:7 at C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\lib\db.js:1504:5 at handleCallback (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\lib\utils.js:96:12) at _callback (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\lib\db.js:1420:5) at C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\lib\db.js:1463:7 at C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:1416:5 at finish (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\auth\scram.js:157:16) at handleEnd (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\auth\scram.js:170:7) at C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\auth\scram.js:264:17 at commandCallback (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:1194:9) at Callbacks.emit (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:119:3) at null.messageHandler (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:358:23) at Socket. (C:\oferdo\oferdo\node_modules\mongoose\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:292:22) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:153:18) at Socket.Readable.push (_stream_readable.js:111:10) at TCP.onread (net.js:531:20)

2

2 Answers

1
votes

Actually, this is nothing to do with incorrectly named files.

You need to make sure that you have the invokeRolesPolicies function defined within your policies file. The minimum required is:

'use strict';

var acl = require('acl');
acl = new acl(new acl.memoryBackend());

exports.invokeRolesPolicies = function () {};

The reason why is that the express.js lib defined in mean.js assumes this is set, and tries to call it, hence the error.

0
votes

You'll get this error if you have an incorrectly named file under your module's server > policies directory, so check there for any inconsistently named files.

EDIT

I see now that it's not the naming of the file but if you have a file in the policies directory that doesn't contain this method, it will produce this error. In my case I had temporarily commented out the code in a file in this directory in preparation for removal.