Open robatronPrime opened 9 months ago
Got the same problem and yes, @robatronPrime solution is really working. I tried to use Webpack config to add alias
"next/dist/shared/lib/router-context$": path.join(
__dirname,
"..",
"..",
"node_modules",
"next/dist/shared/lib/router-context.shared-runtime.js"
),
but it doesn't work...
Provided a fix, your next version was set to latest, when checking the next version the plugin checked for a number, and omitted 'latest' string, setting ur Router Context path to old, resulting in this problem
If you need a quick solution for a cloud deployment like heroku or netlify just use yarn/pnpm/npm install next@14.1, fixes the issue
In
next@14.1.0
therouter-context
file has changed name torouter-context.shared-runtime
.Changing the line at
./node_modules/next-translate-routes/react/withTranslateRoutes.js:38:0
fromvar router_context_1 = require("next/dist/shared/lib/router-context");
tovar router_context_1 = require("next/dist/shared/lib/router-context.shared-runtime");
fixes the issue.However, it would be cool if it new which version of next was being used and changed the import depending on the next version?
Same problem for me.
Maybe anyone had successfully solved the problem for the next-translate-routes v10
with aliases?... I just can't understand why my solution isn't working
i have written a temporary solution, especialy if you need a quick fix for a cloud deployment just add this script in root directory.
const fs = require('fs');
const path = require('path');
/**
* @param {string} filePath - The path to the file.
* @param {string} searchPattern - The RegExp pattern to search for.
* @param {string} replaceString - The string to replace with.
*/
function replaceLineInFile(filePath, searchPattern, replaceString) {
const fileContent = fs.readFileSync(filePath, 'utf8');
const modifiedContent = fileContent.replace(searchPattern, replaceString);
fs.writeFileSync(filePath, modifiedContent);
console.log(`File updated: ${filePath}`);
}
const filePath = path.join(__dirname, 'node_modules', '/next-translate-routes/react/', 'withTranslateRoutes.js');
const searchPattern = /var router_context_1 = require\("next\/dist\/shared\/lib\/router-context"\);/g;
const replaceString = 'var router_context_1 = require("next/dist/shared/lib/router-context.shared-runtime");';
replaceLineInFile(filePath, searchPattern, replaceString);
from there, you just run it before build with node, and then everything should work as expected
Bumping the thread. Would be nice if someone addressed this issue and went through PR's waiting to be merged. 👍🏻
Have the same issue, bumping the thread.
Hi! Sorry that it took so long, but I went through 3 intense months, and had to prioritize. I just release 1.11.0-5, that basically drop support for old next version (<13.5.0), in order to fix this issue. I tried hard to maintain the support, as reflected in the version number, without success. I hope it is ok this time.
In
next@14.1.0
therouter-context
file has changed name torouter-context.shared-runtime
.Changing the line at
./node_modules/next-translate-routes/react/withTranslateRoutes.js:38:0
fromvar router_context_1 = require("next/dist/shared/lib/router-context");
tovar router_context_1 = require("next/dist/shared/lib/router-context.shared-runtime");
fixes the issue.However, it would be cool if it new which version of next was being used and changed the import depending on the next version?