Youths threw bricks and large stones at police officers in a North Yorkshire town.