HUNTINGTON, N.Y. (AP) _ A commuter railroad train rammed into a tractor-trailer stuck at a crossing in this New York City suburb and derailed, slightly injuring 18 of the 40 people aboard, authorities said.

The truck's driver waved in a frantic attempt to warn the westbound Long Island Rail Road train's engineer, but stood clear as the locomotive slammed into his truck Thursday evening, witnesses said.

''It just pushed the trailer right on its side,'' said Bob Morgan, who was working nearby.

LIRR spokesman Mike Charles, asked if the train's engineer had seen the driver waving, said the accident was being investigated.

The locomotive flipped on its side and into a lumberyard next to the tracks and five passenger coaches derailed, said Susan McGowan, a railroad spokeswoman. The only part of the train left on the tracks was a rear engine car.

Two cars on a siding also derailed when they were sideswiped.

The injured, who suffered sprains and minor cuts, were treated at Huntington Hospital, said hospital administrator Ronald Gaudreualt.

No regular train service was scheduled today on the LIRR branch from Huntington to Port Jefferson about 20 miles to the east.