angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Can't load app.component.html with relative path

Open richavyas opened this issue 10 years ago • 27 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Mac OSX (Yosemite)
  2. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here: angular-cli: 1.0.0-beta.14 node: 6.1.0 os: darwin x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc. This app ran successfully with the latest webpack/angular-cli@latest but it's not loading app.component.html with relative path.

source code:

app.component.ts

   styleUrls: ['./app.component.scss'],
   templateUrl: './app.component.html',

Error:

zone.js:1241GET http://localhost:4200/app.component.html 404 (Not Found) zone.js:344 Unhandled Promise rejection: Failed to load app.component.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load app.component.html undefined

Setup info:

Router : upgraded to rc.7 Webpack: "2.1.0-beta.22" angular-cli@latest

  1. The log given by the failure. Normally this include a stack trace and some more information. No error while ng build or serve. Build happens successfully but this does not load files with relative path.
  2. Mention any other details that might be useful. Things work upto certain extent when used complete folder structure like app/app/component.html or app/components/...

Thanks! We'll be in touch soon.

richavyas avatar Sep 22 '16 12:09 richavyas

how module:module.id this thing fix issue? Can anybody explain plz Need to understand logic

sanaattar avatar May 01 '17 08:05 sanaattar

https://stackoverflow.com/questions/39503805/zone-js344-unhandled-promise-rejection-failed-to-load-app-template-html-in-ang

Codefans-fan avatar May 23 '17 08:05 Codefans-fan

@rameshpraja : I get 404: angular2.dev.js:20736 GET http://localhost:3000/app/contact-form.component.html 404 (Not Found) even if i give the path from app directory.

@loumorgsy y should we give moduleId: module.id

when i gave it says cannot find module.

Pl let me know. TIA

sunkarashruthi avatar Jun 19 '17 19:06 sunkarashruthi

templateUrl: './menu.component.html'

to

templateUrl: require('./menu.component.html')

works fine for me..

broni0 avatar Oct 31 '17 09:10 broni0

Had the same problem. Deleting all .map .js files from components/modules/services resolved this issue. Now I have to figure out why the build causes this and how to resolve it. If anyone has any info on how I solve this by configurations in webpack.common/webpack.config please notify me.

TomasKatz avatar Nov 16 '17 10:11 TomasKatz

Deleting the .js and .js.map files from the serving directory and setting compileOnSave: false in tsconfig.json solved the problem for me

Yup, this also worked for me, thanks!

nombrekeff avatar Nov 26 '18 12:11 nombrekeff

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.