jeffwcx / inquirer-select-pro

An inquirer select that supports filtering/searching and multiple selections.
MIT License
8 stars 2 forks source link

Seeing an error when trying to use #1

Closed Peter-Sparksuite closed 4 months ago

Peter-Sparksuite commented 4 months ago

Hey there!

I'm seeing an error appear when trying to use inquirer-select-pro as follows:

Error: require() of ES Module {....removed...}/node_modules/inquirer-select-pro/node_modules/chalk/source/index.js from {...removed...}/node_modules/inquirer-select-pro/dist/index.cjs not supported.
Instead change the require of index.js in {...removed...}/node_modules/inquirer-select-pro/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.

My project is TypeScript, and the use of the standard @inquirer select prompt choice works fine, but not your multi-select.

jeffwcx commented 4 months ago

Hi, I think you may import inquirer-select-pro as a CommonJS module in your project. @inquirer/core also uses chalk, but it uses the chalk^4 version, which provides CommonJS. However, inquirer-select-pro uses the chalk^5 version, which is a pure ESM library. It seems that esbuild has some issues with converting ESM to CommonJS, which I will address in the 1.0 version.

For now, you may need to use the ES module, as the use of CommonJS is currently restricted.

jeffwcx commented 4 months ago

The cjs for version 1.0.0-alpha.6 is now available.

image