I'm working on a project and i would like to build a Monorepo architecture for it.
for now i have two packages:
- front/ contains my React(next) application with typescript
- server/ is an express app using typescript too
Here is my project architecture :
├── Makefile
├── ecosystem.config.js
├── lerna.json
├── package-lock.json
├── package.json
├── packages
│ ├── front
│ │ ├── components
│ │ ├── interfaces
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── pages
│ │ ├── tsconfig.json
│ │ ├── utils
│ │ └── yarn.lock
│ └── server
│ ├── package.json
│ ├── src
│ │ ├── app.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ └── yarn.lock
└── yarn.lock
the file ecosystem.config.js is where i describe all the pm2 proccesses :
module.exports = {
apps: [
{
name: "Front",
cwd: "./packages/front",
script: "yarn",
args: "run dev",
interpreter: "bash",
instances: 1,
max_memory_restart: "1G",
env: {
NODE_ENV: "development",
REACT_APP_API_URL: "http://localhost:8080",
},
env_production: {
NODE_ENV: "production",
}
},
{
name: "Server",
cwd: "./packages/server",
script: "yarn",
args: "run dev",
instances: 1,
interpreter: "bash",
autorestart: true,
watch: true,
max_memory_restart: "1G",
env: {
NODE_ENV: "development",
PORT: "8080",
},
env_production: {
NODE_ENV: "production",
PORT: "8080",
}
}
]
}
this is my lerna.json
{
"npmClient": "yarn",
"packages": [
"packages/*"
],
"useWorkspaces": true,
"version": "0.0.0"
}
Makefile where i set all my commands :
## ------------
## Setup
## ------------
install:
yarn install
npx lerna bootstrap
## ------------
## Dev
## ------------
start:
npx pm2 start
stop:
npx pm2 delete all
when i run the make start (npx pm2 start) command, the 2 proccesses status shows as stopped. And i dont understand why ..
npx pm2 start
[PM2][WARN] Applications Front, Server not running, starting...
[PM2] App [Front] launched (1 instances)
[PM2] App [Server] launched (1 instances)
┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼───────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ Front │ default │ 0.35.3 │ fork │ 10947 │ 0 │ 1 │ stopped │ 0% │ 0b │ max… │ disabled │
│ 1 │ Server │ default │ 0.35.3 │ fork │ 10949 │ 0 │ 1 │ stopped │ 0% │ 0b │ max… │ enabled │
└─────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
and this is what i get after run npx pm2 logs :
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/maximeoger/.pm2/pm2.log last 15 lines:
PM2 | 2020-11-17T16:57:42: PM2 log: App [Front:0] starting in -fork mode-
PM2 | 2020-11-17T16:57:42: PM2 log: App [Front:0] online
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] exited with code [2] via signal [SIGINT]
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] starting in -fork mode-
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] online
PM2 | 2020-11-17T16:57:42: PM2 log: App [Front:0] exited with code [2] via signal [SIGINT]
PM2 | 2020-11-17T16:57:42: PM2 log: App [Front:0] starting in -fork mode-
PM2 | 2020-11-17T16:57:42: PM2 log: App [Front:0] online
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] exited with code [2] via signal [SIGINT]
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] starting in -fork mode-
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] online
PM2 | 2020-11-17T16:57:42: PM2 log: App [Front:0] exited with code [2] via signal [SIGINT]
PM2 | 2020-11-17T16:57:42: PM2 log: Script /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn had too many unstable restarts (16). Stopped. "errored"
PM2 | 2020-11-17T16:57:42: PM2 log: App [Server:1] exited with code [2] via signal [SIGINT]
PM2 | 2020-11-17T16:57:42: PM2 log: Script /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn had too many unstable restarts (16). Stopped. "errored"
/home/maximeoger/.pm2/logs/Front-out-0.log last 15 lines:
/home/maximeoger/.pm2/logs/Server-out-1.log last 15 lines:
/home/maximeoger/.pm2/logs/Front-error-0.log last 15 lines:
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 7: var: command not found
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: syntax error near unexpected token `('
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: `var majorVer = parseInt(ver.split('.')[0], 10);'
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 3: /bin: Is a directory
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 4: /bin: Is a directory
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 5: use strict: command not found
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 7: var: command not found
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: syntax error near unexpected token `('
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: `var majorVer = parseInt(ver.split('.')[0], 10);'
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 3: /bin: Is a directory
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 4: /bin: Is a directory
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 5: use strict: command not found
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 7: var: command not found
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: syntax error near unexpected token `('
0|Front | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: `var majorVer = parseInt(ver.split('.')[0], 10);'
/home/maximeoger/.pm2/logs/Server-error-1.log last 15 lines:
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 7: var: command not found
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: syntax error near unexpected token `('
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: `var majorVer = parseInt(ver.split('.')[0], 10);'
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 3: /bin: Is a directory
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 4: /bin: Is a directory
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 5: use strict: command not found
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 7: var: command not found
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: syntax error near unexpected token `('
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: `var majorVer = parseInt(ver.split('.')[0], 10);'
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 3: /bin: Is a directory
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 4: /bin: Is a directory
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 5: use strict: command not found
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 7: var: command not found
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: syntax error near unexpected token `('
1|Server | /home/maximeoger/.nvm/versions/node/v15.2.0/bin/yarn: line 8: `var majorVer = parseInt(ver.split('.')[0], 10);'
Can you help me to understand this error ? Any help will be very appreciated !
Thanks,
Maxime