Problem running project based on ES6 + Yarn 2 PNP
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 tring to start with pm2 a cluster of app based on yarn 2 PNP and ES6 modules.
Tested with many options combinations and relative/absolute path but without success.
From what I see in logs it's like node requirer needed by yarn PNP are ignored or path not valid.
0|srv | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|srv | Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'koa' imported from /home/vista/pm2pnp/srv/index.js
0|srv | Did you mean to import koa-npm-2.13.4-8aee05a69e-c9a6f9c803.zip/node_modules/koa/lib/application.js?
0|srv | at new NodeError (node:internal/errors:371:5)
0|srv | at packageResolve (node:internal/modules/esm/resolve:884:9)
0|srv | at moduleResolve (node:internal/modules/esm/resolve:929:18)
0|srv | at defaultResolve (node:internal/modules/esm/resolve:1044:11)
0|srv | at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
0|srv | at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
0|srv | at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
0|srv | at link (node:internal/modules/esm/module_job:75:36)
I start the project form it's root with command
> pm2 start pm2.config.js
N.B. Absolute path to be changed in pm2.config.js
How could we reproduce this issue?
I have published the test minimal project here
https://github.com/ftaiolivista/yarn2-pn-es6-pm2-test
I have extracted node args directly from yarn when starting the project with "yarn start"
Supporting information
--- PM2 report ----------------------------------------------------------------
Date : Mon Feb 14 2022 09:41:27 GMT+0100 (Central European Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.1.2
node version : 16.13.2
node path : /home/vista/.yarn/bin/pm2
argv : /home/vista/.nvm/versions/node/v16.13.2/bin/node,/home/vista/.config/yarn/global/node_modules/pm2/lib/Daemon.js
argv0 : node
user : vista
uid : 1000
gid : 10
uptime : 5463min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.1.2
node version : 16.13.2
node path : /home/vista/.yarn/bin/pm2
argv : /home/vista/.nvm/versions/node/v16.13.2/bin/node,/home/vista/.yarn/bin/pm2,report
argv0 : node
user : vista
uid : 1000
gid : 10
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
cpus nb : 8
freemem : 2370134016
totalmem : 20638416896
home : /home/vista
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ srv │ default │ N/A │ cluster │ 183213 │ 2s │ 1 │ online │ 13.7% │ 86.2mb │ vista │ disabled │
└─────┴────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. App csr differs. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
/home/vista/.pm2/pm2.log last 20 lines:
PM2 | 2022-02-14T09:41:24: PM2 log: Stopping app:srv id:0
PM2 | 2022-02-14T09:41:24: PM2 log: App name:srv id:0 disconnected
PM2 | 2022-02-14T09:41:24: PM2 log: App [srv:0] exited with code [0] via signal [SIGINT]
PM2 | 2022-02-14T09:41:24: PM2 log: pid=182803 msg=process killed
PM2 | 2022-02-14T09:41:24: PM2 log: App [srv:0] starting in -cluster mode-
PM2 | 2022-02-14T09:41:24: PM2 log: App [srv:0] online
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 failure from the linked yarn2-pn-es6-pm2-test project, using pm2.config.js and the reported pm2 start pm2.config.js command. Compare the process arguments and module resolution with the working yarn start path. Done means the ES6 application can start in PM2 cluster mode and resolve the koa import under Yarn 2 PnP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100