question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I can not import Image component from next/image

See original GitHub issue
  • mdx-bundler version: ^5.2.1
  • node version: v16.3.0
  • npm version: 7.20.1

Relevant code or config

import * as React from 'react'
import Image from 'next/image'

function EsstentialismGraph() {
  return (
    <div className="mt-4 flex justify-center">
      <Image src={'/essentialism_graph.svg'} 
        alt="Tư tưởng cốt lõi và không cốt lõi"
        layout="intrinsic" 
        width={250} 
        height={300} />
    </div>
    )
}

export default EsstentialismGraph

What you did: Thank you for an amazing project! I try to import EsstentialismGraph component to the MDX file but it turns out I get an error about the process. I figured out the problem was I used Image component from next.

What happened: Screen Shot 2021-08-08 at 17 27 29

Reproduction repository:

Problem description:

Suggested solution:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

2reactions
Arcathcommented, Aug 27, 2021

As far as I am aware next/image needs to be supplied as a global so that it comes from the next.js app iinstead of being imported seperately. The same is true for next/link.

1reaction
nterolcommented, Jul 29, 2022

As far as I am aware next/image needs to be supplied as a global so that it comes from the next.js app iinstead of being imported seperately. The same is true for next/link.

I’m not sure to understand how to do that. I added

globals: { 'next/image': 'nextImage', 'next/link': 'nextLink' }

to the bundleMDX function and provided

import NextImg from 'next/image';
import Link from 'next/link';
/* 
...
*/
getMDXComponent(code, { nextImage: NextImg, nextLink: Link });

to the page component, but still receive this error whenever I import a component using next/image : ReferenceError: process is not defined

Am I missing something here ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't import Image from 'next/image' - Stack Overflow
I've created a NextJS project, but I'm not able to import the Image component. I've already imported other components from NextJS (e.g. Head ......
Read more >
next/image - Next.js
The <Image /> component requires the following properties. src. Must be one of the following: A statically imported image file ...
Read more >
How to add an image in next.js? - Medium
By default, next.js adds lazy load and eager is not good for image optimization. import Image from 'next/image' import mypic from '.
Read more >
How to import image in Next.js ? - GeeksforGeeks
In this article, we will learn to import images in Next.js using the Image component. Image component in Next.js (next/image): Next.js Image ......
Read more >
Image component does not work with Storybook · Issue #18393
js 11 and being able to use image imports like I would in Next. Next's webpack config uses next-image-loader for static image imports....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found