Next.js build fails. Cannot find module next/Link

Hi my build runs fine locally but I’m getting a weird bug when I try to build on render. It’s telling me I cannot find the module next/Link or the type. I’m learning next.js and typescript so I’m not sure which is giving me the problem. The next export is failing locally due to the image optimization api but I believe that is separate to this problem.

Feb 19 02:18:44 AM ==> Running build command ‘yarn; yarn build; yarn next export;’…
Feb 19 02:18:44 AM yarn install v1.22.17
Feb 19 02:18:44 AM [1/4] Resolving packages…
Feb 19 02:18:44 AM success Already up-to-date.
Feb 19 02:18:44 AM Done in 0.29s.
Feb 19 02:18:44 AM yarn run v1.22.17
Feb 19 02:18:44 AM $ next build
Feb 19 02:18:45 AM info - Checking validity of types…
Feb 19 02:18:49 AM Failed to compile.
Feb 19 02:18:49 AM
Feb 19 02:18:49 AM ./src/components/Navigation.tsx:1:18
Feb 19 02:18:49 AM Type error: Cannot find module ‘next/Link’ or its corresponding type declarations.
Feb 19 02:18:49 AM
Feb 19 02:18:49 AM > 1 | import Link from ‘next/Link’;
Feb 19 02:18:49 AM | ^
Feb 19 02:18:49 AM 2 |
Feb 19 02:18:49 AM 3 | export default function Navigation() {
Feb 19 02:18:49 AM 4 | return (
Feb 19 02:18:49 AM error Command failed with exit code 1.
Feb 19 02:18:49 AM info Visit yarn run | Yarn for documentation about this command.

Thanks for any help!

I was able to fix it lol

import Link from 'next/link';

i have no idea but i put next/Link and next/Image into next/link and next/image and it worked

I was able to fix it lol

import Link from 'next/link';

i have no idea but i put next/Link and next/Image into next/link and next/image and it worked

[Discourse post]