algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

'default' is not exported by node_modules/algoliasearch/index.js

Open lukecharle opened this issue 2 years ago • 3 comments

I'm using rollup and experiencing the below error when trying to use import algoliasearch from "algoliasearch";

'default' is not exported by node_modules/algoliasearch/index.js

Yet that index.js does export default?

/* eslint-disable functional/immutable-data, import/no-commonjs */
const algoliasearch = require('./dist/algoliasearch.cjs.js');

/**
 * The Common JS build is the default entry point for the Node environment. Keep in
 * in mind, that for the browser environment, we hint the bundler to use the UMD
 * build instead as specified on the key `browser` of our `package.json` file.
 */
module.exports = algoliasearch;

/**
 * In addition, we also set explicitly the default export below making
 * this Common JS module in compliance with es6 modules specification.
 */
module.exports.default = algoliasearch;

I've tried using @rollup/plugin-commonjs as many others have said but this doesn't resolve anything.

lukecharle avatar Sep 18 '23 17:09 lukecharle

I was able to get this working with rollup using the https://rollupjs.org/tutorial/#using-config-files, not sure what your project is using (e.g. typescript, or javascript), but I was able to bundle it and run a simple algolia "getObject" method.

snolan-ethika avatar Jul 19 '24 00:07 snolan-ethika

I was able to get this working with rollup using the https://rollupjs.org/tutorial/#using-config-files, not sure what your project is using (e.g. typescript, or javascript), but I was able to bundle it and run a simple algolia "getObject" method.

Can you please provide details?

SchulteDev avatar Sep 04 '24 09:09 SchulteDev

I was able to get this working with rollup using the https://rollupjs.org/tutorial/#using-config-files, not sure what your project is using (e.g. typescript, or javascript), but I was able to bundle it and run a simple algolia "getObject" method.

Can you please provide details?

Sure, try changing your "output" format, play around with that and see if that helps.

snolan-ethika avatar Sep 04 '24 15:09 snolan-ethika

i'm getting same issue

dibasdauliya avatar Jan 13 '25 15:01 dibasdauliya

closing as it should be fixed in v5, feel free to re-open if needed

shortcuts avatar Mar 17 '25 14:03 shortcuts