Here the 1874 RLDS edition replaced the plural commandments with the singular commandment. The 1908 RLDS edition restored the original plural, probably by reference to the printer’s manuscript. Also see the discussion under 2 Nephi 5:19 for another example where the RLDS text replaced commandments with commandment.
Elsewhere, when referring to God’s commandment(s), the original text has ten occurrences of the plural “according to the commandments” and two of the singular “according to the commandment” (in Mormon 5:13 and Ether 4:5). So theoretically either reading is possible in 2 Nephi 31:18; the critical text will follow the earliest reading.
Summary: Maintain in 2 Nephi 31:18 the plural form “according to the commandments” (the reading of the earliest textual sources).