Within my NodeJS/TypeScript
project, I am successfully using fluent-ffmpeg
.
To utilize it, I have to import the path
properties from both ffmpeg-installer/ffmpeg
and ffprobe-installer/ffprobe
.
The import for ffmpeg
appears as follows:
import * as ffmpegInstaller from "@ffmpeg-installer/ffmpeg";
This is enabled by the presence of a declaration file named index.d.ts
within the @ffmpeg-installer/ffmpeg
module's types
folder.
However, when it comes to ffprobe
, importing is not possible due to the absence of a similar declaration file. If I try:
import * as ffprobeInstaller from "@ffprobe-installer/ffprobe";
, an error occurs:
A declaration file could not be found for module '@ffprobe-installer/ffprobe'. The '<...>/node_modules/@ffprobe-installer/ffprobe/index.js' implicitly has an 'any' type. You can try
if available, or add a new declaration (.d.ts) file containingnpm i --save-dev @types/ffprobe-installer__ffprobe
ts(7016)declare module '@ffprobe-installer/ffprobe';
Even after running
npm i --save-dev @types/ffprobe-installer__ffprobe
, there is no resolution.
In order to proceed, I use
const ffprobeInstaller = require("@ffprobe-installer/ffprobe");
instead, which effectively works.
Nevertheless, ESLint
raises an issue:
The require statement is not part of the import statement. eslint (@typescript-eslint/no-var-requires)
To address this, I attempted to replace it with:
import ffprobeInstaller = require("@ffprobe-installer/ffprobe");
as recommended in the ESLint
documentation, but then I encounter the A declaration file could not be found... ts(7016)
again.
There are several approaches I could take to resolve this problem:
- Create my own declaration file
- Disable the
no-var-requires
rule or ignore it locally
My question is: How can I comply with ESLint
's no-var-requires
rule without creating a declaration file or disabling the rule?