Having difficulty constructing a full stack application using Express

I've been struggling to configure a full stack app using create-react-app with Express and TypeScript. My main issue is figuring out how to compile the server files into a build folder. I have separate tsconfig files for the server and create-react-app.

The goal is to have the server files go into build/server. The server.ts files are located in ./server, while React files are in ./src.

This is my tsconfig.json file provided by create-react-app:

{ "compilerOptions":

{ "target": "es5",

"lib": ["dom", "dom.iterable", "esnext"],

"allowJs": true,

"skipLibCheck": true,

"esModuleInterop": true,

"allowSyntheticDefaultImports": true,

"strict": true,

"forceConsistentCasingInFileNames": true,

"module": "esnext",

"moduleResolution": "node",

"resolveJsonModule": true,

"isolatedModules": true,

"noEmit": true,

"jsx": "preserve" },

"include": ["src"]}

And here's my tsconfig.server.json file:

{ "extends": "./tsconfig.json",

"compilerOptions":

{ "module": "commonjs",

"outDir": "build/server" },

"include": ["server"]}

When I try to build using

tsc -p tsconfig.server.json

I don't receive any errors, but nothing seems to happen either.

Answer №1

After some investigation, the issue has been resolved.

In my server tsconfig.json file, I had to set "noEmit": false instead of the default value true that create-react-app provides. This change allowed the modifications to be included in the build folder as expected.

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

Encountering an issue while running the ng build --prod command in Angular

I ran into an issue while trying to execute the command ng build --prod in Angular. I've completed my small project and now need to generate the necessary files for uploading to my hosting provider. ERROR - ANGULAR CLI C:\Users\Johan Cor ...

Optionalize keys containing a specific character in their name

Imagine I have an object similar to the following: const obj = { a: 1, "b?": 2, "c?": 3 } The current type of this object is as follows: type Obj = { a: number; "b?": number; "c?": number; } Is there a ...

Module '. ' or its corresponding type declarations cannot be located

While working on my project with TypeScript and using Cheerio, I encountered an issue when trying to compile it with TSC. The compiler threw the following exception: error TS2307: Cannot find module '.' or its corresponding type declarations. 2 ...

What is the proper way to utilize the router next function for optimal performance

I want to keep it on the same line, but it keeps giving me errors. Is there a way to prevent it from breaking onto a new line? const router = useRouter(); const { replace } = useRouter(); view image here ...

Using the updated state value in a React Axios request for dynamic URL usage

I'm looking to make an axios request, but I need a state update with geolocation value beforehand. I attempted the following: const Home = () => { const [latitude, setLatitude] = useState(); const [longitude, setLongitude] = useState(); f ...

Is it possible to import the identical file twice consecutively using html and typescript?

I encountered an issue with an input element in my HTML file. Here's what it looks like: <input type="file" (change)="receiveFile($event)" id="inputFileButton" hidden /> This input element is designed for users to import files. Wh ...

The only information returned from calling mongoose's Model.save() method are the fields { _id, __

I've encountered a problem even though I believe I'm following all the right steps. I'm attempting to save an item from a form into my mongodb collection using mongoose. This is what my schema looks like: // stationmodel.js export const Sta ...

Utilizing query parameters in Next.js

I've been working on a unique Next.js application that incorporates both infinite scroll and a search input feature. The infinite scroll functionality loads 6 additional items whenever the user reaches the bottom of the page. On the other hand, the s ...

Is it possible to launch a React application with a specific Redux state preloaded?

Is there a way to skip navigating through a bulky frontend application in order to reach the specific component I want to modify? I'm curious if it's feasible to save the redux store and refresh my application after every code alteration using t ...

Verify whether a field has been altered in the post-hook of mongoose for the findOneAndUpdate method

Within the controller, I am utilizing findOneAndUpdate to increment a field. This increment is only executed if the condition for an update query has been satisfied. In the event that the field has been incremented, another model needs to be updated as wel ...

Encountered an issue while installing create-react-app through npm, as well as experiencing an error while trying to initialize react

Having trouble installing create-react-app and encountering errors? $ npm install create-react-app npm ERR! code ECONNREFUSED npm ERR! errno ECONNREFUSED npm ERR! FetchError: request to https://registry.npmjs.org/create-react-app failed, reason: connect EC ...

What causes useEffect to run twice in React and what is the best way to manage it effectively?

I'm currently facing an issue with my React 18 project where the useEffect hook is being called twice on mount. I have a counter set up along with a console.log() inside the useEffect to track changes in state. Here's a link to my project on Code ...

The pagination component in React with Material-ui functions properly on a local environment, but encounters issues when deployed

Looking for some assistance with a persistent issue I've run into. Can anyone lend a hand? [x] The problem persists in the latest release. [x] After checking the repository's issues, I'm confident this is not a duplicate. Current Behavior ...

Securing paths using Next.js and Express

Currently, I'm in the process of developing an application with NextJS, Firebase Authentication, and Express. When a user signs up or signs in, Firebase sends me a token that I can use to verify the user and protect certain routes within the app. c ...

Tips on implementing multiple consecutive setState calls in ReactJS

Recently, I discovered that setState is an async call. I'm facing an issue where I need to utilize the updated result from setState immediately after setting it, but due to its async nature, I end up getting the old state value. While researching for ...

Updating parent components through child components in ReactWould you like another unique

In my current project, I am attempting to change the state of the main component labeled App.tsx by using a child component called RemarksView.tsx. I have attempted passing props such as setRemarks and remarks, but unfortunately the state in the parent c ...

Issue with UseState causing a re-render not to be triggered

My orders list state works perfectly on the initial update. However, when an order in the database gets updated, the order list is updated but fails to trigger a re-render even with <...> const [orders, setOrders] = useState([]); useEffect(( ...

Utilizing the arr.push() method to replace an existing value within an array with a new object, rather than simply adding a new

Seeking help to dynamically render a list of components that should expand or shrink based on values being added or removed from an array of custom objects. However, facing an issue where pushing a value into the array only replaces the previous value inst ...

When attempting to set a dynamic src tag for embedding a Google Map in a React application, an X-Frame-Options

I'm attempting to display a specific location using an iframe embed from Google Maps (shown below): <iframe width="100%" height="200" frameBorder="0" scrolling="no" marginHeight={0} marginWidth={0} id="g ...

Configuring the session expiration time in Node.js Express by setting it in the SessionStore rather than in a cookie

Every resource I have come across regarding Express Sessions focuses on setting the cookie expiration times. session.cookie.expires = null; // Browser session cookie session.cookie.expires = 7 * 24 * 3600 * 1000; // Week long cookie However, the cookie ...