Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module Error (Emitted value instead of an instance of Error)

enter image description here

enter image description here

ERROR in ./src/scss/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/scss/styles.scss) Module Error (from ./node_modules/postcss-loader/lib/index.js): (Emitted value instead of an instance of Error) CssSyntaxError: C:\xampp\htdocs\projectA\postGrad-Frontend\src\scss\pages\login.scss:6:13: Can't resolve '../../assets/images/login-bg.jpg' in 'C:\xampp\htdocs\projectA\postGrad-Frontend\src\scss'

Why it is throwing an error. the correct image present in my images. I tried rebuilding the npm rebuild but no luck.

like image 687
Mr world wide Avatar asked Oct 27 '18 18:10

Mr world wide


4 Answers

Just added single slash / in my background:url(/../../assets) and its working as expected as per documentation it means it will look from the current path.

like image 92
Mr world wide Avatar answered Oct 17 '22 14:10

Mr world wide


Replace path from this:

@font-face {
  font-family: 'Effra';
  src: url('assets/fonts/Effra_W_It.ttf') format("truetype");
  font-weight:400;
  font-style: italic;
}

To this:

@font-face {
  font-family: 'Effra';
  src: url("~assets/fonts/Effra_W_It.ttf") format("truetype");
  font-weight:400;
  font-style: italic;
}

The change in the path to file is key: ~assets/

like image 36
redrom Avatar answered Oct 17 '22 13:10

redrom


I received similar error while building an Angular CLI application after upgrading the application from Angular 8 to Angular 10. A component was using an scss file that had a path to an image in the assets folder (e.g. assets/images/test.jpg). This path to the image worked in Angular 8 (e.g. assets/images/test.jpg) but did not work after the upgrade. The build will break with the following error as it was looking for the image file relative to the current directory the component was in. The file would not display on the page also. I changed the path relative to the component's folder such as ../../../../assets/images/test.jpg that resolved the issue.

Error: (Emitted value instead of an instance of Error) CssSyntaxError: C:\myproject\my.component.scss:10:12: Can't resolve './assets/images/test.jpg'

like image 23
Atif Majeed Avatar answered Oct 17 '22 13:10

Atif Majeed


The solution is to add / to the beginning of the path: example: /assets/images/bg-1.png where assets are located in the root under src Folder

like image 1
Yisal Khan Avatar answered Oct 17 '22 13:10

Yisal Khan