Need help running from ecosystem with adding tsconfig-paths/register to Node
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?
I'm writing an ecosystem file for starting a compiled Typescript application and I'm having trouble finding the correct configuration.
Here's the starting call of my application from package.json's script which is actually working:
"cross-env TZ=utc NODE_ENV=development TS_NODE_PROJECT=tsconfig.server.json pm2 start node -- -r tsconfig-paths/register -r ts-node/register/transpile-only dist-srv/server/main.js"
I would like to move to an ecosystem file to support clustering. The current working ecosystem file is this:
{
"apps": [
{
"name": "my-app",
"script": "./node_modules/.bin/ts-node",
"interpreter": "node",
"args":"-r tsconfig-paths/register -r ts-node/register/transpile-only dist-srv/server/main.js",
"watch": false,
"instances": 2,
"exec_mode": "cluster",
"env": {
"production": false,
"TZ": "utc",
"NODE_ENV": "development",
"TS_NODE_PROJECT": "tsconfig.server.json"
}
}
]
}
My problem is that I have to use ts-node even though my files are available in compiled form. That's because I can't just add node to the scriptparam or remove the param entirely. And it would equally fail to add the start script (dist-srv/server/main.js) to script because it would then not be able to resolve the tsconfig paths I'm using.
I also tried using the node_args param instead of args but that didn't work either.
Could you give me some guidance what I could add to the script param to start node right away. Or maybe I missed some parameter constellation that would give it to work even with my start script in the script param?
Supporting information
$ pm2 report
pm2d version : 4.4.0
node version : 12.14.1
...
// let me know if you need more.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the package.json command and the ecosystem configuration using PM2 4.4.0, comparing the script, args, and node_args parameters described in the issue. Trace PM2's ecosystem-file argument handling and document or test the supported way to launch dist-srv/server/main.js with the requested Node preload modules and clustering enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100