reactjsnext.jsi18nextnext-intl

Module not found: Package path ./link is not exported from package\node_modules\next-intl


In my next js app I just merged a branch to another one with major changes, had to resolve conflicts, everything looked just fine, but then after reinstalling next-intl package, got this error:

Module not found: Package path ./link is not exported from package...\node_modules\next-intl (see exports field in ...\node_modules\next-intl\package.json)

. reinstalling did not help and could not google this out either. Can someone help me?

next-intl structure

...\node_modules\next-intl\package.json code:

{
  "name": "next-intl",
  "version": "3.0.0-rc.2",
  "sideEffects": false,
  "author": "Jan Amann <jan@amann.work>",
  "description": "A minimal, but complete solution for internationalization in Next.js apps.",
  "license": "MIT",
  "homepage": "https://next-intl-docs.vercel.app",
  "repository": {
    "type": "git",
    "url": "https://github.com/amannn/next-intl"
  },
  "main": "./dist/index.js",
  "module": "./dist/esm/index.js",
  "typings": "./dist/types/src/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/types/src/index.d.ts",
      "react-server": "./dist/esm/index.react-server.js",
      "default": "./dist/index.js"
    },
    "./server": {
      "types": "./server.d.ts",
      "react-server": "./dist/esm/server.react-server.js",
      "default": "./dist/server.js"
    },
    "./config": {
      "types": "./config.d.ts",
      "default": "./dist/config.js"
    },
    "./middleware": {
      "types": "./middleware.d.ts",
      "default": "./dist/middleware.js"
    },
    "./navigation": {
      "types": "./navigation.d.ts",
      "react-server": "./dist/esm/navigation.react-server.js",
      "default": "./dist/navigation.js"
    },
    "./plugin": {
      "types": "./plugin.d.ts",
      "default": "./dist/plugin.js"
    }
  },
  "files": [
    "dist",
    "server.d.ts",
    "navigation.d.ts",
    "middleware.d.ts",
    "plugin.d.ts",
    "config.d.ts"
  ],
  "keywords": [
    "react",
    "intl",
    "i18n",
    "internationalization",
    "localization",
    "translate",
    "translation",
    "format",
    "formatting",
    "next",
    "next.js"
  ],
  "dependencies": {
    "@formatjs/intl-localematcher": "^0.2.32",
    "negotiator": "^0.6.3",
    "server-only": "0.0.1",
    "use-intl": "3.0.0-beta.3"
  },
  "peerDependencies": {
    "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
    "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
  },
  "devDependencies": {
    "@edge-runtime/vm": "^3.1.3",
    "@size-limit/preset-big-lib": "^8.2.6",
    "@testing-library/react": "^13.0.0",
    "@types/negotiator": "^0.6.1",
    "@types/node": "^17.0.23",
    "@types/react": "^18.2.5",
    "eslint": "^8.46.0",
    "eslint-config-molindo": "^7.0.0",
    "eslint-plugin-deprecation": "^1.4.1",
    "next": "13.5.2",
    "path-to-regexp": "^6.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "rollup": "^3.28.1",
    "rollup-plugin-preserve-directives": "0.2.0",
    "size-limit": "^8.2.6",
    "typescript": "^5.0.0",
    "vitest": "^0.32.2"
  },
  "size-limit": [
    {
      "path": "dist/production/index.js",
      "limit": "12.7 KB"
    },
    {
      "path": "dist/production/navigation.js",
      "limit": "2.6 KB"
    },
    {
      "path": "dist/production/server.js",
      "limit": "1.3 KB"
    },
    {
      "path": "dist/production/middleware.js",
      "limit": "5.9 KB"
    }
  ],
  "scripts": {
    "build": "rm -rf dist && rollup -c",
    "test": "TZ=Europe/Berlin vitest",
    "lint": "eslint src test && tsc --noEmit",
    "size": "size-limit"
  }
}

Solution

  • I just ran into the same problem and could resolve it based on the answer to this (related, although refering to a different function) github issue: https://github.com/amannn/next-intl/issues/364 - using the server components beta version works: https://next-intl-docs.vercel.app/docs/getting-started/app-router-server-components

    npm install next-intl@3.0.0-beta.19