Why is jsfiddle saying the reference is undefined

Viewed 60

I'm quite new to javascript and jsfiddle. I've been able to toy around with other fiddles that I find, but setting one up myself has proved difficult.

I'm attempting to use a library from npm to get a proof of concept for how it might work. I'm not sure why my import of the module is not working with jsfiddle.

What am I missing to get my fiddle working?

  • used the resourced bar to import the unpkg script
https://unpkg.com/browse/json-query@2.2.2/index.js
  • tried using the method outlined in the package readme
var json = [...]

jsonQuery('[DisplayText]', json)
1 Answers

When I follow the unpkg link I see that it has requires such as:

var State = require('./lib/state')

The problem is not only can the browser not understand require, it doesn't have files like ./lib/state available.

I think the problem here is that you are trying to download the raw source, which needs to be built with something like webpack before it can be used in the browser.

Related