How many integers $n$ with $0\leq n < 840$ are there such that $840$ divides $n^8-n^4+n-1$?

$ \textbf{(A)}\ 1
\qquad\textbf{(B)}\ 2
\qquad\textbf{(C)}\ 3
\qquad\textbf{(D)}\ 6
\qquad\textbf{(E)}\ 8
$
1. First, we note that \( 840 = 3 \cdot 5 \cdot 7 \cdot 8 \). We need to find the integers \( n \) such that \( 0 \leq n < 840 \) and \( 840 \) divides \( n^8 - n^4 + n - 1 \). This means we need \( n^8 - n^4 + n - 1 \equiv 0 \pmod{840} \).

2. We will consider the congruences modulo \( 3 \), \( 5 \), \( 7 \), and \( 8 \) separately.

3. **Modulo 3:**
   - Since \( n^2 \equiv 1 \pmod{3} \) for \( n \) such that \( \gcd(n, 3) = 1 \), we have:
     \[
     n^8 \equiv 1 \pmod{3}, \quad n^4 \equiv 1 \pmod{3}
     \]
     \[
     n^8 - n^4 + n - 1 \equiv 1 - 1 + n - 1 \equiv n - 1 \pmod{3}
     \]
     Therefore, \( n \equiv 1 \pmod{3} \).

4. **Modulo 5:**
   - Since \( n^4 \equiv 1 \pmod{5} \) for \( n \) such that \( \gcd(n, 5) = 1 \), we have:
     \[
     n^8 \equiv 1 \pmod{5}, \quad n^4 \equiv 1 \pmod{5}
     \]
     \[
     n^8 - n^4 + n - 1 \equiv 1 - 1 + n - 1 \equiv n - 1 \pmod{5}
     \]
     Therefore, \( n \equiv 1 \pmod{5} \).

5. **Modulo 8:**
   - Since \( \varphi(8) = 4 \), we have \( n^4 \equiv 1 \pmod{8} \) for \( n \) such that \( \gcd(n, 8) = 1 \), we have:
     \[
     n^8 \equiv 1 \pmod{8}, \quad n^4 \equiv 1 \pmod{8}
     \]
     \[
     n^8 - n^4 + n - 1 \equiv 1 - 1 + n - 1 \equiv n - 1 \pmod{8}
     \]
     Therefore, \( n \equiv 1 \pmod{8} \).

6. **Modulo 7:**
   - Since \( n^6 \equiv 1 \pmod{7} \), we have:
     \[
     n^8 \equiv n^2 \pmod{7}, \quad n^4 \equiv n^2 \pmod{7}
     \]
     \[
     n^8 - n^4 + n - 1 \equiv n^2 - n^2 + n - 1 \equiv n - 1 \pmod{7}
     \]
     Therefore, \( n \equiv 1 \pmod{7} \) or \( n \equiv 3 \pmod{7} \).

7. **Combining the congruences using the Chinese Remainder Theorem:**
   - For \( n \equiv 1 \pmod{3} \), \( n \equiv 1 \pmod{5} \), \( n \equiv 1 \pmod{8} \), and \( n \equiv 1 \pmod{7} \):
     \[
     n \equiv 1 \pmod{840}
     \]
     This gives us \( n = 1 \).

   - For \( n \equiv 1 \pmod{3} \), \( n \equiv 1 \pmod{5} \), \( n \equiv 1 \pmod{8} \), and \( n \equiv 3 \pmod{7} \):
     Using the Chinese Remainder Theorem, we find another solution \( n \) in the interval \( 0 \leq n < 840 \).

8. Therefore, there are two solutions in total.

The final answer is \(\boxed{2}\).