Adam Harkus
Adam Harkus

Reputation: 2210

React: Cannot find module or its corresponding type declarations.ts

I'm trying to access an asset to use in a css declaration...

import FooterBackgroundDesktop from "../../assets/register-bg.png";

"background-image": `url(${FooterBackgroundDesktop})`

However, although the path to assets and the filename is correct, I get the following error:

Cannot find module '../../assets/register-bg.png' or its corresponding type declarations.ts(2307)

Any ideas?

Upvotes: 1

Views: 484

Answers (1)

NAZIR HUSSAIN
NAZIR HUSSAIN

Reputation: 1

use like this

"background-image": url("../../assets/register-bg.png")

or you can do this

let FooterBackgroundDesktop = "../../assets/register-bg.png";

"background-image": url(FooterBackgroundDesktop)

Upvotes: 1

Related Questions