I maintain a node.js library and I tried to add the following piece of code:
const curlirize = require('axios-curlirize')
And I get the following error (on node
version 19.x
): SyntaxError: Cannot use import statement outside a module
.
I saw this answer on SO and I tried adding "type": "module"
in my package.json
and that did not work either.
Although master build is passing, PR build is failing. What am I doing wrong? I looked at another library with the same package structure as me that uses require('axios-curlirize')
and that library works just fine!
PS: I actually do not want type: module
since I need it to be CJS - but I want to understand why other code works with the require
works but not mine!