hozana / next-translate-routes

Flexible and translated routes for Next.js without custom server
MIT License
115 stars 30 forks source link

Module not found: Can't resolve 'next/dist/shared/lib/router-context' #97

Open jaumamyfront-ender opened 2 months ago

jaumamyfront-ender commented 2 months ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch next-translate-routes@1.10.2 for the project I'm working on.

library next-translate-routes didnt work ,i got error like this ===>Module not found: Can't resolve 'next/dist/shared/lib/router-context' https://nextjs.org/docs/messages/module-not-found Import trace for requested module: ./node_modules/next-translate-routes/index.js ./pages/_app.tsx Using external babel configuration from /Users/bogdan/Documents/work/landing/.babelrc.js โจฏ ./node_modules/next-translate-routes/react/withTranslateRoutes.js:38:1 Module not found: Can't resolve 'next/dist/shared/lib/router-context' https://nextjs.org/docs/messages/module-not-found Import trace for requested module: ./node_modules/next-translate-routes/index.js ./pages/_app.tsx GET / 500 in 7289ms

Here is the diff that solved my problem:

diff --git a/node_modules/next-translate-routes/react/withTranslateRoutes.js b/node_modules/next-translate-routes/react/withTranslateRoutes.js
index f9d2804..e2cff27 100644
--- a/node_modules/next-translate-routes/react/withTranslateRoutes.js
+++ b/node_modules/next-translate-routes/react/withTranslateRoutes.js
@@ -35,7 +35,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
 };
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.withTranslateRoutes = void 0;
-var router_context_1 = require("next/dist/shared/lib/router-context");
+// var router_context_1 = require("next/dist/shared/lib/router-context");
+var router_context_1 = require("next/dist/shared/lib/router-context.shared-runtime");
 var router_1 = require("next/router");
 var react_1 = __importStar(require("react"));
 var ntrData_1 = require("../shared/ntrData");

This issue body was partially generated by patch-package. Zrzut ekranu 2024-09-2 o 15 03 49 (2)