Skip to content


 Zabbix
 Grafana
 Prometheus
 React Three Fiber
 Threejs and TypeScript
 SocketIO and TypeScript
 Blender Topological Earth
 Sweet Home 3D
 Design Patterns Python
 Design Patterns TypeScript
   
 Course Coupon Codes
Three.js and TypeScript
Kindle Edition
$6.99 $9.99 Paperback 
$22.99 $29.99




Design Patterns in TypeScript
Kindle Edition
$6.99 $9.99 Paperback
$11.99 $19.99




Design Patterns in Python
Kindle Edition
$6.99 $9.99 Paperback
$11.99 $19.99




Create the Start Script

Video Lecture

Create the Start Script Create the Start Script

Description

When running on production, we don't need to use nodemon, concurrently or have TSC watching our source code for any changes we make to the files.

TypeScript has already compiled our code into JavaScript compatible for the browser and NodeJS. So we also don't need TypeScript to be installed on production.

So,

We can create a more simplified starting script that will just start the main server.js in NodeJS.

Open the package.json and add the highlighted line below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
    "name": "tssocktutorial",
    "version": "1.0.0",
    "description": "",
    "scripts": {
        "dev": "concurrently -k \"tsc -p ./src/server -w\" \"tsc -p ./src/client -w\" \"nodemon ./dist/server/server.js\"",
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node ./dist/server/server.js"
    },
    "author": "Sean Bradley",
    "license": "ISC",
    "dependencies": {
        "bootstrap": "^4.6.1",
        "express": "^4.18.1",
        "jquery": "^3.6.0",
        "socket.io": "^4.5.1",
        "socket.io-client": "^4.5.1"
    },
    "devDependencies": {
        "@types/bootstrap": "^4.6.2",
        "@types/express": "^4.17.13",
        "@types/jquery": "^3.5.6",
        "@types/node": "^18.0.4",
        "@types/socket.io-client": "^1.4.36",
        "concurrently": "^7.2.2",
        "nodemon": "^2.0.19",
        "typescript": "^4.7.4"
    }
}

You can now start your project by typing

npm start

Note

Note that we only used npm start and not npm run start. The run option is not necessary. npm start is an alias for npm run start. You can use the longer version if you prefer.

Other aliases you may see used occasionally are,

npm test

npm restart

npm stop