简体   繁体   中英

ERROR in ./src/app/svg.component.ts Module not found: Error: Can't resolve './svg.component.svg'

There is a live example from the official doc thats not working: https://angular.io/generated/live-examples/template-syntax/stackblitz.html

The live example error says: Import error, can't find file: ./svg.component.svg

If I download the example and npm install it, I got the error:

ERROR in ./src/app/svg.component.ts
Module not found: Error: Can't resolve './svg.component.svg' in 'C:\Users\Elias\Desktop\New folder\src\app'

The svg.component.ts has this portion of code:

import { Component } from '@angular/core';
@Component({
  selector: 'app-svg',
  templateUrl: './svg.component.svg',

It seems that the component is asking for an .svg file. I don't know how to get it.

You are trying to reference a file that don't exist, and you are trying to reference an svg template from a css which also won't work.

Just add a .svg file containing your svg template to your directory and that should work fine. See the image below.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM