3

I have installed the @angular/compiler-cli globally and added the following tsconfig-aot.json to my client directory:

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "types": []
  },
    "exclude": [
        "../node_modules"
    ],

  "angularCompilerOptions": {
   "genDir": "aot",
   "skipMetadataEmit" : true
 }
}

as recommended in the angular docs. I then run ngc -p tsconfig-aot.json in my client directory but get the following error:

Error: Compilation failed. Resource file not found: C:/Users/George/Source/Repos/docs/client/components/home/client/components/home/home.html

because that resource isn't there.. my home.html is at C:/Users/George/Source/Repos/docs/client/components/home/home.html, tsc works fine and I ahve been using JIT compilation and have a working app, so what is AOT looking in the wrong place for my files?

George Edwards
  • 8,979
  • 20
  • 78
  • 161

1 Answers1

0

In the component ts file you should change the 'templateUrl' to a relative path and add 'moduleId: module.id'.

Example, from:

@Component ({
    selector: "login",
    templateUrl:'app/components/login/login.component.html'
})

to:

@Component ({
    selector: "login",
    moduleId: module.id,
    templateUrl:'login.component.html'
})

That solved my issue, hope it helps...

Loves2Develop
  • 774
  • 1
  • 8
  • 29