'Import js file outside project directory into typescript

I have a small node project I am trying to migrate to TS.

I used to use some js files in my local system at the location '/opt/nodejs/' like const common = require('/opt/nodejs/common')

But I cannot do this in typescript despite having "allowJs": true and fumbling with paths and rootDirs

My esbuild fails with Could not resolve "/opt/nodejs/common.js"

background: this is how aws lambda gives me access my shared dependencies (shared layer) but I think what i am facing is a typescript issue



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source