'How to make a production ready node.js server run when built?
I have created a node.js server and everything works in dev. I even have a docker instance and when building it it all works.
I wondered how could I make a minimized build for production but so far I have not been able to figure it out.
My package.json:
{
"name": "rugbe",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"build": "tsc -p .",
"dev": "npx ts-node-dev --prefer-ts true --no-notify -r tsconfig-paths/register --watch src --transpile-only index.ts"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.1",
"express": "^4.17.2",
"helmet": "^5.0.2"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16.11.22",
"nodemon": "^2.0.15",
"ts-node": "^10.4.0",
"ts-node-dev": "^1.1.8",
"tsconfig-paths": "^3.12.0",
"ttypescript": "^1.5.13",
"typescript": "^4.5.5",
"typescript-transform-paths": "^3.3.1"
}
}
When I run npm run bild I get:
[email protected] build
tsc -p .
But nothing starts?
when I run the npm run dev I get.
npx ts-node-dev --prefer-ts true --no-notify -r tsconfig-paths/register --watch src --transpile-only index.ts
[INFO] 23:27:01 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.5.5)
App running on port 5000
index.ts:
import App from "./src/app";
App.listen(5000);
console.log("App running on port 5000");
Overal project structure
What is the correct script here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

