I made a small nestjs webapp, it connects to a local mssql database and works fine... Except if I try to launch it using pm2.
yarn start:dev
works (it translates to nest start --watch
)yarn start:prod
also works fine (it translates to node dist/main
)nodemon build/main.js
also works fineBut if I try to launch my app running pm2 start build/main.js
I get DB connection errors: TypeError: The "config.server" property is required and must be of type string
.
My DB connection parameters are currently stored in a .env file. I load them running env.config()
and it's working fine for the other three running methods I listed. I've tried to change the parameters to include quotes and double quotes, with no luck:
db_host = localhost
db_host = 'localhost'
db_host = "localhost"
What am I doing wrong?
We just found out that changing the syntax from pm2 start
to something like pm2 start npm --name "myApp" -- run start:prod
worked.