Skip to content

Commit 02268c3

Browse files
committed
fixed the demo-app-remix so it runs as expected with npm run dev.
-changed references to server.js in the npm scripts to server.ts -installed ts-node as a devdependency -add 'export {}' to the top of server.ts to fix an error related to isolatedModules=true in the tsconfig
1 parent adfead2 commit 02268c3

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

demo-app-remix/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"scripts": {
55
"build": "remix build",
66
"dev": "npm-run-all build --parallel \"dev:*\"",
7-
"dev:node": "cross-env NODE_ENV=development nodemon --require dotenv/config ./server.js --watch ./server.js",
7+
"dev:node": "cross-env NODE_ENV=development nodemon --require dotenv/config ./server.ts --watch ./server.ts",
88
"dev:remix": "remix watch",
9-
"start": "cross-env NODE_ENV=production node ./server.js",
9+
"start": "cross-env NODE_ENV=production node ./server.ts",
1010
"typecheck": "tsc"
1111
},
1212
"dependencies": {
@@ -19,7 +19,8 @@
1919
"isbot": "^3.6.5",
2020
"morgan": "^1.10.0",
2121
"react": "^18.2.0",
22-
"react-dom": "^18.2.0"
22+
"react-dom": "^18.2.0",
23+
"ts-node": "^10.9.2"
2324
},
2425
"devDependencies": {
2526
"@remix-run/dev": "^1.14.1",

demo-app-remix/server.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
const path = require("path");
2-
const express = require("express");
3-
const compression = require("compression");
4-
const morgan = require("morgan");
5-
const { createRequestHandler } = require("@remix-run/express");
1+
export {}; //JR: added to fix this error message: 'server.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
2+
const path = require('path');
3+
const express = require('express');
4+
const compression = require('compression');
5+
const morgan = require('morgan');
6+
const { createRequestHandler } = require('@remix-run/express');
67

7-
const BUILD_DIR = path.join(process.cwd(), "build");
8+
const BUILD_DIR = path.join(process.cwd(), 'build');
89

910
const app = express();
1011

1112
app.use(compression());
1213

1314
// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header
14-
app.disable("x-powered-by");
15+
app.disable('x-powered-by');
1516

1617
// Remix fingerprints its assets so we can cache forever.
17-
app.use(
18-
"/build",
19-
express.static("public/build", { immutable: true, maxAge: "1y" })
20-
);
18+
app.use('/build', express.static('public/build', { immutable: true, maxAge: '1y' }));
2119

2220
// Everything else (like favicon.ico) is cached for an hour. You may want to be
2321
// more aggressive with this caching.
24-
app.use(express.static("public", { maxAge: "1h" }));
22+
app.use(express.static('public', { maxAge: '1h' }));
2523

26-
app.use(morgan("tiny"));
24+
app.use(morgan('tiny'));
2725

2826
app.all(
29-
"*",
30-
process.env.NODE_ENV === "development"
27+
'*',
28+
process.env.NODE_ENV === 'development'
3129
? (req: any, res: any, next: any) => {
3230
purgeRequireCache();
3331

@@ -39,7 +37,7 @@ app.all(
3937
: createRequestHandler({
4038
build: require(BUILD_DIR),
4139
mode: process.env.NODE_ENV,
42-
})
40+
}),
4341
);
4442
const port: number | string = process.env.PORT || 3003;
4543

0 commit comments

Comments
 (0)