Unitech / Unitech/pm2

issue with ts-node on Windows

Open
#4,962 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

When running pm2 start with a ts-node script on Windows 10, I get an error inside ts-node. I don't have the issue when running the ts-node command directly from a Powershell

How could we reproduce this issue?

My ecosystem contains:

module.exports = {
  apps : [{
    name: 'pier-admin-development',
    script: './node_modules/.bin/ts-node-dev',
    watch: '.',
    exec_mode: 'fork',
    args: '--files ./src/main.ts',
    max_memory_restart: '150M',
    time: true, // add time to logs
  }]
};

Running pm2 start gives:

[PM2][WARN] Applications pier-admin-development not running, starting...
[PM2] App [pier-admin-development] launched (1 instances)
┌─────┬───────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼───────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ pier-admin-development    │ default     │ 1.0.0   │ fork    │ 2248     │ 0      │ 1    │ stopped   │ 0%       │ 0b       │ olivi    │ enabled  │
└─────┴───────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

(status=stopped and not errored) and pm2 logs:

PS D:\devts\pier\pier-admin-develop> pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
C:\Users\olivi\.pm2\logs\pier-admin-development-out.log last 15 lines:
C:\Users\olivi\.pm2\logs\pier-admin-development-error.log last 15 lines:
0|pier-adm | 2021-01-16T17:31:32: D:\devts\pier\pier-admin-develop\node_modules\.bin\ts-node-dev:2
0|pier-adm | 2021-01-16T17:31:32: basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
0|pier-adm | 2021-01-16T17:31:32:           ^^^^^^^
0|pier-adm | 2021-01-16T17:31:32:
0|pier-adm | 2021-01-16T17:31:32: SyntaxError: missing ) after argument list
0|pier-adm | 2021-01-16T17:31:32:     at wrapSafe (internal/modules/cjs/loader.js:979:16)
0|pier-adm | 2021-01-16T17:31:32:     at Module._compile (internal/modules/cjs/loader.js:1027:27)
0|pier-adm | 2021-01-16T17:31:32:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|pier-adm | 2021-01-16T17:31:32:     at Module.load (internal/modules/cjs/loader.js:928:32)
0|pier-adm | 2021-01-16T17:31:32:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
0|pier-adm | 2021-01-16T17:31:32:     at Object.<anonymous> (C:\Users\olivi\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:33:23)
0|pier-adm | 2021-01-16T17:31:32:     at Module._compile (internal/modules/cjs/loader.js:1063:30)
0|pier-adm | 2021-01-16T17:31:32:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
0|pier-adm | 2021-01-16T17:31:32:     at Module.load (internal/modules/cjs/loader.js:928:32)
0|pier-adm | 2021-01-16T17:31:32:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)

but running directly D:\devts\pier\pier-admin-develop\node_modules\.bin\ts-node-dev --files ./src/main.ts works fine...
EDIT: The same config works on Linux (Ubuntu & Raspbian)

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Sat Jan 16 2021 17:52:49 GMT+0100 (heure normale d’Europe centrale)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.0
node version         : 14.15.0
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,C:\Users\olivi\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js
argv0                : node
user                 : undefined
uid                  : N/A
gid                  : N/A
uptime               : 46min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.0
node version         : 14.15.0
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,C:\Users\olivi\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report
argv0                : C:\Program Files\nodejs\node.exe
user                 : olivi
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : win32
type                 : Windows_NT
cpus                 : Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
cpus nb              : 8
freemem              : 1679581184
totalmem             : 16953622528
home                 : C:\Users\olivi
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼───────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ pier-admin-development    │ default     │ 1.0.0   │ fork    │ 0        │ 0      │ 15   │ errored   │ 0%       │ 0b       │ olivi    │ enabled  │
└─────┴───────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------

(I looked at #2675 but does not seem to be related)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Windows 10 case using the shown ecosystem configuration and compare pm2 start with the direct ts-node-dev command. Start from the pm2 start entry point and the reported lib/ProcessContainerFork.js stack frame; done means the configured TypeScript script launches under PM2 on Windows without parsing ts-node-dev as JavaScript.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, typescript
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.