  We study the structure of anomalies in general heterotic string theories by
considering general 2-dimensional $\mathcal{N}=(0,1)$ supersymmetric quantum
field theories (SQFTs), without assuming conformal invariance nor the correct
central charges. First we generalize the precise notion of the $B$-field
introduced by Witten. Then we express the target space anomalies by invariants
of SQFTs. Perturbative anomalies correspond to the Witten index of some class
of SQFTs, while global anomalies correspond to a torsion version of the Witten
index. The torsion index gives some of the invariants of SQFTs suggested by
topological modular forms, and is expected to be zero for the cases that are
relevant to actual heterotic string theories.
