You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a named import like import { Twilio } from "twilio"; fails on node in ESM mode because node uses cjs-module-lexer to statistically analyze imports. Twilio's OpenAI generator generates code that cjs-module-lexer can't lex to determine the named exports.
Steps to Reproduce
Create test.mjs (forces node to treat as ESM).
Add import { Twilio } from "twilio";
Run node test.mjs
Code Snippet
import{Twilio}from"twilio";
Exception/Log
import { Twilio } from "twilio";
^^^^^^
SyntaxError: Named export 'Twilio' not found. The requested module 'twilio' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
Technical details:
twilio-node version: 5.0.0
node version: 20.12.2
The text was updated successfully, but these errors were encountered:
benasher44
changed the title
Generated JS code doesn't work with cjs-module-lexer
Generated JS code doesn't work with node ESM due to cjs-module-lexer
May 8, 2024
Issue Summary
Using a named import like
import { Twilio } from "twilio";
fails on node in ESM mode because node uses cjs-module-lexer to statistically analyze imports. Twilio's OpenAI generator generates code that cjs-module-lexer can't lex to determine the named exports.Steps to Reproduce
import { Twilio } from "twilio"
;node test.mjs
Code Snippet
Exception/Log
Technical details:
The text was updated successfully, but these errors were encountered: