3

I'm trying to deploy my Angular + NestJS application on my Ubuntu server with PM2 and NGINX. I have build my server, that listens to port 3003. Here is the content of the dist folder :

enter image description here

I then used PM2 as follows:

pm2 start ./main.js --name my-backend

If I try to go on my server IP address, on port 3003, e.g. http://99.99.99.99:3003 nothing happen, I get a page that says we can't access the website, with error code ERR_CONNECTION_REFUSED

Do you know what I did wrong ?

EDIT Well I did something wrong because I have the following error : TextEncoder is not defined

enter image description here

Nicolas Ferrari
  • 61
  • 1
  • 11
  • 1
    Could you share a list of running apps: `pm2 list` and some logs: `pm2 logs`. More info at: https://pm2.keymetrics.io/docs/usage/quick-start/ – Robert-Jan Kuyper Nov 29 '21 at 21:22
  • @Robert-JanKuyper oh yeah, I forgot to check the logs... I edited the post with the error I get. Seems to be related to mongodb , I'm gonna check that – Nicolas Ferrari Nov 29 '21 at 22:16
  • 1
    Can you provide more details such as the package.json and the code how you connect with Mongo. – Robert-Jan Kuyper Nov 30 '21 at 10:13
  • @Robert-JanKuyper I just managed to make it work. I thank you for your help. I found the solution here https://stackoverflow.com/questions/19697858/referenceerror-textencoder-is-not-defined I think I need to upgrade npm and node so that I can have the latest versions of those modules. I started on ubuntu 18.4 that I upgraded to 20.4 but I didn't upgrade the npm and node versions. I think my problem is solved ^^ – Nicolas Ferrari Nov 30 '21 at 10:34

1 Answers1

0

The issue was that a node module had an error: mongodb-connection-string-url/node_modules/whatwg-url/lib/encoding.js was the problem. I had to edit the file, then use this solution : ReferenceError: TextEncoder is not defined

I think I need to upgrade my NPM and Node on Ubuntu, so that I can have the latest versions, as I'm running node v10 and can go to v14.

Nicolas Ferrari
  • 61
  • 1
  • 11