I am facing an issue with my TypeScript file when trying to import third-party libraries.
import * as _ from 'lodash'; // Successfully imported
import * as moment from 'moment'; // Successfully imported
import {vsprintf} from 'sprintf-js'; // Compiler error
While the first two imports work fine, I encounter an error with the sprintf-js import:
Error TS2307: Cannot find module 'sprintf-js'.
Even though I have ensured that sprintf-js
is in my node_modules
directory, the compiler seems to be unable to recognize it. I suspect that there may be a difference in how sprintf-js operates compared to lodash or moment, causing TypeScript to reject it. How can I resolve this issue?