Search code examples
apostrophe-cms

Apostrophecms: TypeError: req.__ns is not a function


after upgrading to v2.105.0 I'm getting this error all the time.

TypeError: req.__ns is not a function at Object.self.getCreateSingletonOptions (/../node_modules/apostrophe/lib/modules/apostrophe-areas/lib/browser.js:26:23) at Object.self.pushCreateSingleton (/../node_modules/apostrophe/lib/modules/apostrophe-module/index.js:637:26) at Object.self.pageBeforeSend (/../node_modules/apostrophe/lib/modules/apostrophe-areas/lib/browser.js:18:10) at Immediate._onImmediate (/../node_modules/apostrophe/index.js:598:20) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5)

downgrading to 2.104.0 helps, but is there is a way to solve it?


Solution

  • If you are overriding the apostrophe-express module, you need to update your lib/modules/apostrophe-express/index.js. Comparing to the current version, it seems you need to add the following line at 413:

    self.apos.app.use(self.apos.modules['apostrophe-i18n'].namespacesMiddleware);
    

    Assuming that line 412 is this: self.apos.app.use(self.apos.i18n.init);

    Well, at least this fixed the exact same error for me.