Search code examples
angulartypescriptangular-universal

Error: Invalid tsconfig - src/tsconfig.app.json


I was trying to install Angular Universal to an existing project, so I ran the following commands:

npm i @nguniversal/express-engine
ng generate universal --client-project website

But after running the second line I get the below error:

Invalid tsconfig - src/tsconfig.app.json

I don't really know why this error is persisting, I've looked at the tsconfig.app.json file and everything looks fine. Below are the files:

tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "files": [
    "atc-main.ts",
    "main.ts",
    "polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts",
    "typings.d.ts"
  ]
}

tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "esnext",
    "skipLibCheck": true,
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es2015",
    "typeRoots": ["../node_modules/@types"],
    "baseUrl": ".",
    "paths": {
      "@app/*": ["./app/*"],
      "@account/*": ["./account/*"],
      "@shared/*": ["./shared/*"],
      "@node_modules/*": ["../node_modules/*"],
      "@angular/*": ["../node_modules/@angular/*"],
      "@metronic/*": ["./assets/metronic/*"]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictTemplates": true,
    "strictInputTypes": false,
    "strictAttributeTypes": false,
    "strictOutputEventTypes": false,
    "strictDomEventTypes": false,
    "strictLiteralTypes": false,
    "strictInjectionParameters": false
  }
}


Solution

    1. Your tsconfig.app.json was missing compilerOptions.
    2. Check src/ reference in files. Same for "atc-main.ts", is the location reference okay? Does "typings.d.ts" exist?
    3. Validate all lines, s.t. they point to something that exists.
    {
      "extends": "./tsconfig.json",
      "compilerOptions": {
        "outDir": "./out-tsc/app",
        "types": ["node"]
      },
      "files": [
        "src/atc-main.ts"
        "src/main.ts",
        "src/polyfills.ts"
      ],
      "include": [
        "src/**/*.d.ts",
        "typings.d.ts"
      ]
    }