Phoenix and brunch

It’s not an issue with npm or Brunch, but the author of that package.

Essentially, the author forgot to specify the entry point of the app, meaning that if you require it, you’ll get an error because there’s “nothing” to require or import.

For the JavaScript, you want to do this:

const JSONViewer = require('jquery.json-viewer/json-viewer/jquery.json-viewer.js')

or

import JSONViewer from 'jquery.json-viewer/json-viewer/jquery.json-viewer.js'

However, you’ll get an error that jQuery is undefined, because again the package author has not written this package to be imported or required through npm. He/she assumes you’ll put it in a script tag under a jQuery script tag (jQuery is assumed to be in global scope).

So it’s a broken package and your only solution is to download the CSS and JS files, though that will break too because the JS file doesn’t import jQuery, it expects it in global scope.

Sorry :confused:

1 Like