heracek / practical-monorepo-nx

Practical monorepo with Nx
https://www.landing.ciklum.com/sc-js-practical-monorepo-with-nx
12 stars 6 forks source link

getting errors when trying to run backend #1

Open chrisdraws opened 1 week ago

chrisdraws commented 1 week ago

Trying to run the backend via the "yarn dev" command and getting the following error. Frontend works perfectly. I've tried changing my node version, I've tried changing localhost to 127.0.0.1 in different places. Nothing seems to solve this. Enjoyed your youtube video and I'm now trying to actually follow along and run the code base.

err Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
 From event:
    at _registerHandshakeCmd (/home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/lib/connection.js:745:11)
    at /home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/lib/connection.js:57:11
    at new Promise (<anonymous>)
    at Connection.connect (/home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/lib/connection.js:56:16)
    at Object.createConnection (/home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/promise.js:31:36)
    at /home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:52:1
    at step (/home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:33:1)
    at Object.next (/home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:14:45)
    at /home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:8:1
    at new Promise (<anonymous>) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3306,
  fatal: true
}
Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
 From event:
    at _registerHandshakeCmd (/home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/lib/connection.js:745:11)
    at /home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/lib/connection.js:57:11
    at new Promise (<anonymous>)
    at Connection.connect (/home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/lib/connection.js:56:16)
    at Object.createConnection (/home/{username}/Projects/research/practical-monorepo-nx/backend/node_modules/mariadb/promise.js:31:36)
    at /home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:52:1
    at step (/home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:33:1)
    at Object.next (/home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:14:45)
    at /home/{username}/Projects/research/practical-monorepo-nx/backend/build/webpack:/src/libs/connection.ts:8:1
    at new Promise (<anonymous>)
heracek commented 1 week ago

Hi @chrisdraws, thank you for raising this issue.

This seems to be issue with ENV variables. It seems that I accidentally added .env file to .gitignore. And because of it backend is trying to connect to MySQL database. Default .env is setup so that it uses mock data instead of MySQL.

I've pushed the apps/quacker-backend/.env file to final and master branches: https://github.com/heracek/practical-monorepo-nx/blob/final/apps/quacker-backend/.env

If you are on initial-state branch please copy this file to backend/.env.

heracek commented 5 days ago

Hi @chrisdraws, did it help?

chrisdraws commented 4 days ago

yes it did!! I continued with the tutorial and you do eventually add them back in when converting your frontend and backend to NX. :) thanks for your help. Do you have any recommendations on more advanced NX tutorials? Your's was great, but I'd like to have something for my team to use to really learn NX inside and out. :)

heracek commented 3 days ago

Great, I’m glad that it helped.

For more advanced/expert level knowledge about Nx I would recommend those two free ebooks: