2

After updating next.js to 13, the storybook build fails.
Below is a version of the storybook.
I have no idea how to solve this problem.
If anyone can help me figure it out, please let me know.

error

ERR! => Failed to build the preview
ERR! Module not found: Error: Can't resolve 'next/dist/next-server/lib/router-context' in '/Users/web/node_modules/next-router-mock/dist/MemoryRouterProvider'
 "@storybook/addon-actions": "^6.5.16",
 "@storybook/addon-essentials": "^6.5.16",
 "@storybook/addon-interactions": "^6.5.16",
 "@storybook/addon-links": "^6.5.16",
 "@storybook/builder-webpack5": "^6.5.16",
 "@storybook/jest": "0.0.10",
 "@storybook/manager-webpack5": "^6.5.16",
 "@storybook/react": "^6.5.16",
 "storybook-addon-next": "^1.7.1",
 "storybook-addon-next-router": "^4.0.2",
 "next-router-mock": "^0.9.1",

I searched the Internet but could not find a similar event.

I searched the Internet but could not find a similar event.

aaa
  • 69
  • 5

1 Answers1

0

Been there.

Fix is simple

import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider/next-13';

Mind the /next-13 part in the end - it's crucial

Kostiantyn Ko
  • 2,087
  • 1
  • 18
  • 16