Next.js Discord

Discord Forum

Issue "Module not found"

Answered
West African Crocodile posted this in #help-forum
Open in Discord
West African CrocodileOP
Hi all 😄 . I am trying to import URL of images into constants folder, so i map over different images, but am getting "module not found error" anyone knows if i am doing anything wrong? Thanks in advance

code and error:
Answered by West African Crocodile
in my componend code there was regular <img> element and i swapped it with <Image>..
View full answer

17 Replies

Plott Hound
you shouldn't need to import the images like that. you can just reference them as you already are in your imageURL.
Can you show your jsconfig file? Just wanna check if the module path alias is set correctly.
@Plott Hound you shouldn't need to import the images like that. you can just reference them as you already are in your imageURL.
West African CrocodileOP
yeah, sorry i was zig-zagging between solutions so i tried it both. but problem is it won't show image on my page anyway if i use it like that i get this:
@Clown Can you show your jsconfig file? Just wanna check if the module path alias is set correctly.
West African CrocodileOP
ofc here it is:
@Clown Also you seem to importing the images incorrectly: https://nextjs.org/docs/app/building-your-application/optimizing/images#local-images
West African CrocodileOP
might be, i was looking for jsmastery tutorial not too long ago.. and i saw he did same and it works perfectly for him:
this is code there
@West African Crocodile might be, i was looking for jsmastery tutorial not too long ago.. and i saw he did same and it works perfectly for him:
Well i dont know if this used to work or works still but for solving your problem why not just do it the way the docs tell you to do it :/
West African CrocodileOP
just did some stuff and it works thank you for your time guys ❤️
West African CrocodileOP
in my componend code there was regular <img> element and i swapped it with <Image>..
Answer
West African CrocodileOP
i still dont understand why it works for other guy
with "img"
but i guess it works here
Alright mark this as the answer :sunglasses_1: