Error in Angular SSR: Build failed due to project reference without "composite" setting set to true

Currently facing an issue while developing an Angular App with SSR. When using npm run build:ssr, the following errors are displayed:

ERROR in [...]/tsconfig.json
[tsl] ERROR
      TS6306: Referenced project '[...]/tsconfig.app.json' must have setting "composite": true.

ERROR in [...]/tsconfig.json
[tsl] ERROR
      TS6306: Referenced project '[...]/tsconfig.server.json' must have setting "composite": true.

Attempts to resolve by adding the key to tsconfig.app.json and tsconfig.server.json were made, but unsure where exactly to include it:

tsconfig.app.json (and tsconfig.server.json accordingly)

{
    "extends": "./tsconfig.base.json",
    "compilerOptions": {
        "outDir": "./out-tsc/app",
        "types": [],
        "composite": true   // <-- generates error below
    },
    "files": [
        "src/main.ts",
        "src/polyfills.ts"
    ],
    "include": [
        "src/**/*.d.ts"
    ],
    "exclude": [
        "src/test.ts",
        "src/**/*.spec.ts"
    ],
    "composite": true   // <-- no effect
}

However, after including the key as advised above, encountered the following error during compilation for each typescript file:

ERROR in error TS6304: Composite projects may not disable declaration emit.

(Clearly, this approach is incorrect...)

Key Details:

  • Angular v 10.0.5
  • SSR support added through @nguniversal/express-engine
  • ng serve functions properly

Key Files:

{project dependencies}

Project Structure:

{angular project setup}

Seeking assistance from the community as I navigate my way through this newfound challenge of implementing SSR. Any guidance or suggestions would be greatly appreciated. Thank you!

Answer №1

First step: Insert composite: true into the compilerOptions section of your tsconfig.app.json file as shown below:

/* For more details on this configuration file, visit: https://angular.io/config/tsconfig. */
{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": [],
    "composite": true
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

Check out the image of tsconfig.app.json here

Second step: Close and reopen vscode

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to add a hyperlink to a cell in an Angular Grid column

I need help creating a link for a column cell in my angular grid with a dynamic job id, like /jobs/3/job-maintenance/general. In this case, 3 is the job id. I have element.jobId available. How can I achieve this? Here is the code for the existing column: ...

A powerful trio: Axios, Typescript, and Promises

I am facing a TypeScript dilemma. I have a REST method that is being called within my http library by Vue action. I want the resolve() method to return the typed array, but if I do not convert it within the action.ts "then" method, I get a '.length do ...

How can I customize a Vue component slot in Storybook 8.0.6 using Vue 3.4 and Typescript to display various subcomponents within a story?

Incorporating a variety of sub-components into my Vue 3 component based on context is proving to be a challenge. Utilizing slots seems to be the solution in Vue 3, but I'm struggling to make it work within Storybook 8, which I'm using to showcase ...

The 'string[]' type cannot be assigned to the 'string | ParsedUrlQueryInput | null | undefined' type in Next.js and Typescript

I'm facing an issue while attempting to transfer an array of strings from one page to another in Next.js using <Link href={{ pathname: "/model", query: data }}>. The problem arises when the query parameter is red underlined: Type &apos ...

Determining the quantity of variations within a union in Typescript

Is it possible to determine the number of types in a union type in Typescript, prior to runtime? Consider the following scenario: type unionOfThree = 'a' | 'b' | 'c'; const numberOfTypes = NumberOfTypes<unionOfThree>; c ...

Leveraging async pipe along with ngIf

Given the status property defined and initialized as shown below: public status:Promise<String>; constructor() { this.status = this.getStatus(); } public getStatus():Promise<String>{ return new Promise((resolve,reject)=>{ ...

Can Angular be used to dynamically filter a JSON object to display only the fields that match a specified filter text?

Sorry if this question has already been asked; I couldn't find the solution. Here is my issue: In my Angular app, I am retrieving a complex JSON object from a web service. I then present this JSON object to the user in tree format using ngx json vie ...

Browser not reflecting changes made to Angular 2 code

Currently facing a challenging issue with my express/angular2 app. Despite using nodemon and seeing the Express code updating fine, I am experiencing issues where my components and services are not updating when I reload the page in the browser. Even aft ...

The Angular Universal Starter is running smoothly on local environments, but encountering difficulties when attempting to launch on the

My current challenge involves running Angular Universal Starter on a Centos server. Executing build:ssr and serve:ssr locally works without any issues. After transferring the dist folder to the server, I updated nodejs, npm, and pm2 to their latest ver ...

Retrieving source in Angular from an async function output within a specified time limit

I have a quick query :). I'm attempting to retrieve the image src from an async function, but so far, I haven't had much success. This is what I have: <img [src]="getProductImage(articleNumber)"/> and in my TypeScript file: publi ...

Unable to fulfill the pledge

I'm struggling to receive the promise from the backend after making a get request. Can anyone help me figure out what I might be doing wrong? makeLoginCall(_username: string, _password: string) { let promise = new Promise((resolve, reject) => ...

What's the best way to add animation to the send icon while hovering over the button?

<div class="text-center"> <button [disabled]="btnStatus" class="btn btn-secondary buttonSend" type="submit"> <div [hidden]="btnStatus"> Send Message&nbsp;&nbs ...

Encountered a problem when implementing flowbite in a project using NextJS and TypeScript

I recently added tailwind and flowbite to my NextJS project. After importing "flowbite" in the _app.tsx file, I encountered the following error message: ReferenceError: document is not defined at Object.366 (D:\shopflo\next-tailwin ...

What is the TypeScript declaration for the built-in 'net' NodeJS types?

I'm currently working on developing a TCP client application and it seems like the 'net' package in NodeJs will be perfect for what I need. However, I've run into an issue finding the TypeScript definitions for this package. If you hav ...

Is there a way to assign API data as inner HTML using Lit?

Need help setting inner html of html elements with a get request Any suggestions on how to achieve this? import { LitElement, html, css } from "lit"; import { customElement } from "lit/decorators.js"; import axios from "axios" ...

Creating a setup with Angular 2+ coupled with Webpack and a Nodejs

I have successfully configured Angular2+webpack along with NodeJs for the backend. Here is a basic setup overview: webpack.config.js: var webpack = require('webpack') var HtmlWebpackPlugin = require('html-webpack-plugin') var Extract ...

Utilizing Angular to retrieve a property from a JSON object and exhibit it as an image

I'm facing a challenge with displaying an image from JSON that is stored on an online API. Please excuse my limited knowledge in Angular as I have only been working with it for 2 weeks. The issue arises when I try to access the "image1" property from ...

Typescript causing undefined React Router match issue

Currently, I am working on a basic eCommerce Proof of Concept using react and TypeScript. Unfortunately, I am facing an issue where I am unable to pass props to a product detail page or access the match containing the params. This is how my Routes pages a ...

Combining the namespace and variable declarations into a single statement

Currently, I am facing an issue with creating a declaration file for the third-party library called node-tap. The main challenge lies in properly declaring types for the library. // node_modules/a/index.js function A() { /* ... */ } module.exports = new A ...

How can I subtract a value from my array in Angular?

I've been troubleshooting this problem for a while now and I'm hoping that someone here can assist me with finding a solution. The issue at hand involves an array object containing various values such as id, title, amountCounter. Specifically, t ...