We report on the first detection of C3N- and C5N- towards the cold dark core TMC-1 in the Taurus region, using the Yebes 40 m telescope. The observed C3N/C3N- and C5N/C5N- abundance ratios are 140 and 2, respectively; that is similar to those found in the circumstellar envelope of the carbon-rich star IRC+10216. Although the formation mechanisms for the neutrals are different in interstellar (ion-neutral reactions) and circumstellar clouds (photodissociation and radical-neutral reactions), the similarity of the C3N/C3N- and C5N/C5N- abundance ratios strongly suggests a common chemical path for the formation of these anions in interstellar and circumstellar clouds. We discuss the role of radiative electronic attachment, reactions between N atoms and carbon chain anions Cn-, and that of H- reactions with HC3N and HC5N as possible routes to form CnN-. The detection of C5N- in TMC-1 gives strong support for assigning to this anion the lines found in IRC+10216, as it excludes the possibility of a metal-bearing species, or a vibrationally excited state. New sets of rotational parameters have been derived from the observed frequencies in TMC-1 and IRC+10216 for C5N- and the neutral radical C5N.