serve
serve copied to clipboard
PM2 treats serve like a CommonJS Module
Description
I ran into the problem that PM2 thinks the package is not a es-module package even-tough it is. So I am getting Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
After some investigation I found out that pm2 loads the serve package from [...]/node/v14.20.0/bin. Its a binary and there is no package-json so PM2 fails to categorize.
Is there any way to fix this from the "serve"-side.
Thanks :)
Library version
14.0.1
Node version
v14.20.0
Same issue
my workaround is to change working directory to where the package.json locates, then run the pm2 command.
$ file $(which serve)
/usr/local/bin/serve: symbolic link to ../lib/node_modules/serve/build/main.js
$ cd /usr/local/lib/node_modules/serve
$ pm2 start build/main.js