1

Hi recently I was updating my Angular project from v8 to v17. Here I am facing this issue:

Module ./src/app/shared/components/carousel/carousel.component.scss?ngResource - Error: Module Error (from ./node_modules/postcss-loader/dist/cjs.js):
/home/sysadmin/Downloads/Angular Upgrade/Angular8to17/trooya/src/app/shared/components/carousel/carousel.component.scss:13:19: Can't resolve './src/assets/images/bg-register.png' in '/home/sysadmin/Downloads/Angular Upgrade/Angular8to17/trooya/src/app/shared/components/carousel'

Here is the carousal.component.scss content:

.logo-container {
  width: 100%;
  height: 4rem;
  margin: 0.5rem 0;
  position: absolute;
  justify-content: center;

  img {
    height: 100%;
  }
}

.carousel-container {
  background: url(src/assets/images/bg-register.png) 50% 80% / cover no-repeat;
  height: 100%;
  display: flex;
  align-items: center;

  .oc-container {
    width: 100%;
  }
}

I checked for cjs.js is present or not in node_modules, it is present: enter image description here

Please help resolving the issue!

1
  • What happens if you change the bg image to use relative import? url("~src/assets/images/bg-register.png") Commented Jun 7, 2024 at 8:51

1 Answer 1

1

The error indicates that there was a problem finding the background image specified in the .carousel-container.

A fix might be to use relative import, like so:

url("~src/assets/images/bg-register.png")

Credit to this answer: https://stackoverflow.com/a/62952041/4529555

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.