Dakota Transmission troubles

I have a 2002 Dodge Dakota 4WD and 3.9L. Driving yesterday, I stepped on gas and tach rose but truck didn’t go any faster. Check engine light came on and is still on. Tried manual shifting of automatic transmission and it worked. Now when in drive the transmission seems to slip for a little while from a dead stop but then is ok. Any ideas on the problem or what it may cost and where might be a good place to take it?