Determine how many grams of Al must react with 2.5 M NaOH in order to produce 40 mL of hydrogen gas at 22°C and 1.02 bar

Aluminum will not react with NaOH. Sodium (Na) is higher on the activity series than Aluminum.

If you are referring to Al + 3HCl => AlCl3 + (3/2)H2 then you have a reaction that will produce hydrogen gas. Assuming rewrite ... How many grams of Al will be needed to react with 2.50M HCl (assumed to be in excess of minimum amount needed) to generate 40.0ml of hydrogen gas at 22^oC and 1.02 bar?

Using Ideal Gas Law PV=nRT, solve for n=moles of H2...
n = PV/RT
P = 1.02bar = 0.9869-Atm
V = 40.0-ml = 0.040-L
R = 0.08206 L-Atm/mol-K
T = 22-deg C = 295-K
n = (0.9869Atm)(0.040L)/(0.08206 L-atm/mol-K)(295K) = 0.00163 mole H2(g)

Reaction:
Al + 3HCl => Al(Cl)3 + (3/2)H2(g)
1-mole Al + Excess HCl => 1-mole Al(Cl)3 + (3/2)-mole H2(g)

Using Ratio & Proportion ...
(1-mole Al)/(X) = [(3/2)-mole H2(g)]/(0.00163-mole H2(g)
Cross multiply and solve for (X) ...
X = [(2)(0.00163)/(3)]-mole Al
=(0.0011 mole Al)
=(0.0011 mole Al)(27 g/mole)
= 0.0294-gms Aluminum needed => 40-ml H2(g) at 22-deg.C in an excess of HCl.