Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
Open
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?
Running my application with pm2-runtime i receive the following error message before my server eventually starts.
> next_api_1 | 2021-07-15T09:24:07: PM2 log: Launching in no daemon mode
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:0] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:0] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:1] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:1] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:2] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:2] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:3] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:3] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:4] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:4] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:5] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:5] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:6] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:6] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:7] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:7] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:8] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:8] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:9] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:9] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:10] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:10] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:11] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:11] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:12] starting in -cluster mode-
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:12] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:13] starting in -cluster mode-
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:13] online
> next_api_1 | 2021-07-15T09:24:07: PM2 log: App [api:14] starting in -cluster mode-
> next_api_1 | 2021-07-15T09:24:08: PM2 log: App [api:14] online
> next_api_1 | 2021-07-15T09:24:08: PM2 log: App [api:15] starting in -cluster mode-
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | 2021-07-15T09:24:08: PM2 log: App [api:15] online
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Failed to load Typescript interpreter: Cannot find module 'ts-node/register'
> next_api_1 | Require stack:
> next_api_1 | - /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
> next_api_1 | Server Running On: 0.0.0.0:3000
How could we reproduce this issue?
ecosystem.config.js
module.exports = {
apps: [
{
name: "api",
script: "src/server.ts",
instances: "max",
exec_mode: "cluster",
interpreter: "./node_modules/.bin/ts-node",
interpreter_args: "--require ts-node/register --require tsconfig-paths/register",
merge_logs: true,
max_restarts: 10,
},
],
};
Dockerfile
FROM node:14.17.1-alpine3.13
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install pm2 -g
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "pm2-runtime", "deploy/ecosystem.config.js" ]
Supporting information
// Inside docker container
/usr/src/app # pm2 report
--- PM2 report ----------------------------------------------------------------
Date : Thu Jul 15 2021 09:32:23 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.1.0
node version : 14.17.1
node path : not found
argv : /usr/local/bin/node,/usr/local/bin/pm2-runtime,deploy/ecosystem.config.js
argv0 : node
user : undefined
uid : 0
gid : 0
uptime : 8min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.1.0
node version : 14.17.1
node path : not found
argv : /usr/local/bin/node,/usr/local/bin/pm2,report
argv0 : node
user : undefined
uid : 0
gid : 0
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
cpus nb : 16
freemem : 53608787968
totalmem : 67363123200
home : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ api │ default │ 1.0.0 │ cluster │ 18 │ 8m │ 0 │ online │ 0% │ 189.7mb │ root │ disabled │
│ 1 │ api │ default │ 1.0.0 │ cluster │ 25 │ 8m │ 0 │ online │ 0% │ 191.0mb │ root │ disabled │
│ 2 │ api │ default │ 1.0.0 │ cluster │ 33 │ 8m │ 0 │ online │ 0% │ 189.9mb │ root │ disabled │
│ 3 │ api │ default │ 1.0.0 │ cluster │ 41 │ 8m │ 0 │ online │ 0% │ 189.7mb │ root │ disabled │
│ 4 │ api │ default │ 1.0.0 │ cluster │ 49 │ 8m │ 0 │ online │ 0% │ 189.7mb │ root │ disabled │
│ 5 │ api │ default │ 1.0.0 │ cluster │ 57 │ 8m │ 0 │ online │ 0% │ 189.2mb │ root │ disabled │
│ 6 │ api │ default │ 1.0.0 │ cluster │ 65 │ 8m │ 0 │ online │ 0% │ 189.3mb │ root │ disabled │
│ 7 │ api │ default │ 1.0.0 │ cluster │ 73 │ 8m │ 0 │ online │ 0% │ 189.4mb │ root │ disabled │
│ 8 │ api │ default │ 1.0.0 │ cluster │ 81 │ 8m │ 0 │ online │ 0% │ 189.6mb │ root │ disabled │
│ 9 │ api │ default │ 1.0.0 │ cluster │ 89 │ 8m │ 0 │ online │ 0% │ 188.4mb │ root │ disabled │
│ 10 │ api │ default │ 1.0.0 │ cluster │ 97 │ 8m │ 0 │ online │ 0% │ 189.2mb │ root │ disabled │
│ 11 │ api │ default │ 1.0.0 │ cluster │ 105 │ 8m │ 0 │ online │ 0% │ 189.1mb │ root │ disabled │
│ 12 │ api │ default │ 1.0.0 │ cluster │ 113 │ 8m │ 0 │ online │ 0% │ 190.1mb │ root │ disabled │
│ 13 │ api │ default │ 1.0.0 │ cluster │ 125 │ 8m │ 0 │ online │ 0% │ 188.8mb │ root │ disabled │
│ 14 │ api │ default │ 1.0.0 │ cluster │ 141 │ 8m │ 0 │ online │ 0% │ 189.8mb │ root │ disabled │
│ 15 │ api │ default │ 1.0.0 │ cluster │ 149 │ 8m │ 0 │ online │ 0% │ 189.3mb │ root │ disabled │
└─────┴────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
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 with lib/ProcessContainer.js, named in the require stack, and compare its TypeScript interpreter handling with the ecosystem.config.js settings. Reproduce the report using the supplied Dockerfile and pm2-runtime command. Done means the configuration runs without the repeated “Cannot find module 'ts-node/register'” messages while the API remains online.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100