I am developing an app in NodeJS, and need to use old packages.
The problem is that in their instructions the usage suggested is with require
:
var xxx = require("xxx");
but I get an ELSint error Do not use "require".
If I simply replace require
with import
I get:
TS7016: Could not find a declaration file for module xxx.
What would be the correct solution for this problem?
you can use dynamic imports
import { createRequire } from 'module';
const require = createRequire(import.meta.url); // Why? relative to absolute path within a module (Browser / server)
const xxx = require('xxx');
BTW, have you tried lazy loading? await import('xxx')