https://codesandbox.io/s/nuxtnuxtjs-typescript-pub29
// Uncomment this 2 lines:
// const Test = IocContainer.get("TestClass");
// console.log("Test", Test);
Worked on the server and in the browser. To avoid errors with https://github.com/inversify/InversifyJS
Error is only on server.
This error occurs only on the server, I do not understand why.
This code works:
if (process.browser) {
const Test = IocContainer.get("TestClass");
console.log("Test", Test);
}
This code does not work:
if (process.server) {
const Test = IocContainer.get("TestClass");
console.log("Test", Test);
}
I spent 6 hours on this problem and now it is important for me to solve it as soon as possible. Please give me some hint how to solve this problem.
I have used Inversify.JS many times with Nuxt, but it seems this error has appeared after the 2.4.0+ version, I checked it out.
Help me please. I am sure that the reason for the error in the Nuxt.js.
Add to your nuxt.config
render: {
bundleRenderer: {
runInNewContext: false
}
}
@aldarund you are my savior! I spent 6 hours searching for a problem... Thank you very much! 馃槃馃帀
I found documentation about this.
This is not so important, but I just want to clarify: nothing bad will happen to my application if I change this setting? (it is planned to be large)
bundleRenderer option:
It is recommended to not use this option as Nuxt.js is already providing best SSR defaults and misconfiguration might lead to SSR problems.
Perhaps you see some other best workaround for the error?
Who is interested: runInNewContext: 'once' also gives my error.
It only affects dev mode. In production its false already. You can remove it and try to build rpoduction build and there wont be error too
Most helpful comment
It only affects dev mode. In production its false already. You can remove it and try to build rpoduction build and there wont be error too