I encountered an issue with the following error:
./components/Hero.tsx:2:0
Module not found: Can't resolve '../media/HeroVideo1-Red-Compressed.m4v'
1 | import React, { useState } from 'react';
> 2 | import Video from '../media/HeroVideo1-Red-Compressed.m4v';
3 | import { Button } from './SharedStyles';
4 | import styled from 'styled-components'
5 | import { MdKeyboardArrowRight, MdArrowForward } from 'react-icons/md';
Import trace for requested module:
./pages/index.tsx
https://nextjs.org/docs/messages/module-not-found
Thetsconfig.json
file includes the following configurations:
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
To address this issue, I followed the top answer (by score) on this question, where I added index.d.ts
to ./media
with the declaration declare module '*.m4v'
. Although this resolved the squiggly lines in Hero.tsx
, it led to the error mentioned above on the client side.
I also tried the solutions provided in this question, but they did not yield the desired outcome. I am exploring alternatives to placing the video in the public
folder. Any suggestions would be greatly appreciated.