Cannot find module '/opt/nodejs/logger'

Viewed 19

I know there are already many similar questions and answers to same problem, but I've tried all possible solutions and it's still not working. I have a aws layer (coded in a separate git repo) that I'm trying to utilize in my lambda repo. Here's the structure-

src
 code
  studenthelper
    index.js
 shared
  logger.ts
index.js
jsconfig.json
package.json

And here's my content-

jsconfig.json

{
"compilerOptions":{
 "baseUrl":".",
 "paths":{
   "/opt/nodejs/*":["src/shared/*"]
}
}
}

index.js(inside studenthelper)

const {errorCodes} = require('/opt/nodejs/logger');

I keep getting error cannot find module '/opt/nodejs/logger'.

I have to use the aws layer inside shared folder which is a typescript file that I can't change and my existing code too is restricted to JavaScript. Please help.

0 Answers
Related