Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import qs is undefined, but works with require

I have a code that runs on NodeJS 14 on Google Cloud Functions, I am using typescript with tsc to compile my code.

import qs from 'qs'

console.log(`qs >>> ${qs})

The code above logs (in production)

qs >>> undefined

I think the problem is my tsconfig, could someone help to check if there is some something non usual on my configuration?

If I use require('qs') the code works.

My tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017",
    "allowSyntheticDefaultImports": true
  },
  "compileOnSave": true,
  "include": ["src", "tests"]
}
like image 747
Rodrigo Avatar asked Oct 20 '25 15:10

Rodrigo


1 Answers

Try it with:

import * as qs from 'qs'
like image 156
Roman P. Avatar answered Oct 23 '25 04:10

Roman P.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!