Skip to content

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

@jaumamyfront-ender

Description

@jaumamyfront-ender

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions