npm start does not work on vps (sovled)

I checked the haxe official examples. While npm install and npm start worked fine locally. But when I tried to put them on my hosting's Vps it gave me this error:

[root@server colyseus-official-examples]# npm start

colyseus-examples@1.0.1 start /var/www/html/001-codex/colyseus-official-examples
ts-node-dev --respawn --transpile-only src/index.ts

sh: ts-node-dev: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! colyseus-examples@1.0.1 start: ts-node-dev --respawn --transpile-only src/index.ts
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the colyseus-examples@1.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-05-15T09_47_00_680Z-debug.log


Here is the content of log file:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle colyseus-examples@1.0.1~prestart: colyseus-examples@1.0.1
6 info lifecycle colyseus-examples@1.0.1~start: colyseus-examples@1.0.1
7 verbose lifecycle colyseus-examples@1.0.1~start: unsafe-perm in lifecycle true
8 verbose lifecycle colyseus-examples@1.0.1~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/html/001-codex/colyseus-official-examples/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
9 verbose lifecycle colyseus-examples@1.0.1~start: CWD: /var/www/html/001-codex/colyseus-official-examples
10 silly lifecycle colyseus-examples@1.0.1~start: Args: [ '-c', 'ts-node-dev --respawn --transpile-only src/index.ts' ]
11 info lifecycle colyseus-examples@1.0.1~start: Failed to exec start script
12 verbose stack Error: colyseus-examples@1.0.1 start: ts-node-dev --respawn --transpile-only src/index.ts
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:210:5)
12 verbose stack at maybeClose (internal/child_process.js:1021:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
13 verbose pkgid colyseus-examples@1.0.1
14 verbose cwd /var/www/html/001-codex/colyseus-official-examples
15 verbose Linux 2.6.32-042stab120.19
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
17 verbose node v12.13.0
18 verbose npm v6.12.0
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error colyseus-examples@1.0.1 start: ts-node-dev --respawn --transpile-only src/index.ts
23 error spawn ENOENT
24 error Failed at the colyseus-examples@1.0.1 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

Hi @vishwasgagrani!

By the error message, it seems that devDependencies listed under package.json were not installed during npm install:

sh: ts-node-dev: command not found

If you use npm install --only=dev the development dependencies should be installed as well.

Let me know if that works for you!

Tried using -only=dev , but does not seems to solve the problem. Same error again. It is asking for peer dependencies though.

npm install --only=dev
npm WARN @colyseus/social@0.10.9 requires a peer of express-jwt@^5.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN colyseus-examples@1.0.1 No repository field.

audited 346 packages in 4.513s
found 1 low severity vulnerability
[root@server colyseus-official-examples]# npm start

colyseus-examples@1.0.1 start /var/www/html/001-codex/colyseus-official-examples
ts-node-dev --respawn --transpile-only src/index.ts

sh: ts-node-dev: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! colyseus-examples@1.0.1 start: ts-node-dev --respawn --transpile-only src/index.ts
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the colyseus-examples@1.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-05-17T09_12_57_957Z-debug.log

[root@server colyseus-official-examples]#

Anyway I looked into package.json and saw this list:

"@types/cors": "^2.8.6",
"@types/express": "^4.17.1",
"copyfiles": "^2.4.1",
"rimraf": "^2.7.1",
"ts-node": "^8.1.0",
"ts-node-dev": "^1.0.0-pre.63",
"typescript": "^3.4.5"

And after installing ts-node-dev using:
npm i ts-node-dev --save-dev

I see the server running at 2567
Listening on ws://localhost:2567

Got it working for now. Thanks.