Fuse: TypeError: Cannot read property 'location' of undefined

Created on 1 Dec 2017  路  4Comments  路  Source: krisk/Fuse

Getting a TypeError when trying to use Fuse with node 9.2.0

/home/olian04/Documents/Projects/xs/node_modules/fuse.js/dist/fuse.js:557
    var _ref$location = _ref.location,
                             ^

TypeError: Cannot read property 'location' of undefined
    at new Fuse (/home/olian04/Documents/Projects/xs/node_modules/fuse.js/dist/fuse.js:557:30)
    at querySegments.reduce (/home/olian04/Documents/Projects/xs/app/index.js:10:24)
    at Array.reduce (<anonymous>)
    at xs (/home/olian04/Documents/Projects/xs/app/index.js:9:32)
    at Object.<anonymous> (/home/olian04/Documents/Projects/xs/demo/test.js:3:16)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)

Fuse is the only package installed, and this fails:

const Fuse = require('fuse.js');
new Fuse([]); // Fails here!

Versions:
Fuse: 3.2.0
Node: 9.2.0
Npm: 5.5.1
Ubuntu: 17.04

Stale

Most helpful comment

I encountered the same issue. Pass in an empty options object.

new Fuse([], {});

All 4 comments

I encountered the same issue. Pass in an empty options object.

new Fuse([], {});

We had a similar issue trying to use Fuse.js with a React project. Our problem was that we were passing in the options from a react component's state.

var fuse = new Fuse(data, this.state.options);

We sloved the problem by directly putting our options object into the constructor for Fuse(). I.e.

var fuse = new Fuse(data, {keys: ['title', 'description'], id: 'id'});

Hey guys, i have same issue here, but my array not is empty, any one have a solution?

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Was this page helpful?
0 / 5 - 0 ratings