Cannot get Data from GPS module

I am new to Arduino programming and I purchased a GPs module (NEO-6M GPS GY-GPS6MV2).

when I upload empty code or any code that doesn't have anything to do with serial ports and open the serial monitor it shows me my Gps data and constantly updates.

However when I do

"Serial.begin(9600);"
the data stream stops and every time I open the serial monitor I get
"⸮⸮⸮⸮⸮⸮⸮⸮)b⸮⸮b⸮⸮b⸮⸮⸮b⸮⸮b⸮⸮b⸮⸮b⸮Šb⸮⸮b⸮⸮b⸮⸮b"
or
"$GPRMC,⸮51.00,A,A*71", but i can't access this data

"Serial.println(Serial.available());"
it prints out a loop of zero even though when I go and upload an empty code again and look at the serial monitor it shows me my GPS location

when I try to read and print the serial data nothing prints out, I don't know if I was supposed to set up the device somehow, I am not sure what I should do

After reading the How to use this forum post, please post the code (using code tags) and a wiring diagram.

It sounds like you have connected the GPS unit to pins 0 and 1. You can't do that and use those pins for program loading and serial monitor output at the same time. Instead, use software serial and other pins to read the GPS output.

Here is my simple GPS test code for a NEO6M with GPS TX connected to SoftwareSerial using pin 4 for RX to an Uno (or similar), GPS RX not connected. Note the serial monitor baud rate set to 115200.

//gps test

#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, -1); // RX, TX

void setup()
{
   // Open serial communications
   Serial.begin(115200);
   // set the data rate for the SoftwareSerial port
   mySerial.begin(9600);
}

void loop()
{
   if (mySerial.available())
   {
      Serial.print(char(mySerial.read()));
   }
}