jsonpath icon indicating copy to clipboard operation
jsonpath copied to clipboard

Support pkg (executable nodejs app)

Open Mihailoff opened this issue 6 years ago • 7 comments

https://www.npmjs.com/package/pkg can't handle pathed aesprim module with error

Error: Cannot find module 'esprima'

At the moment I don't use @ literal in json paths so the dirty hack to make it work would be replacing https://github.com/dchester/jsonpath/blob/master/lib/aesprim.js with

module.exports = require('esprima')

Any better ideas?

Mihailoff avatar Mar 12 '18 19:03 Mihailoff

I have almost same error.

I require library json-schema-faker which uses jsonpath

i have error Error: Cannot find module 'esprima' when i try to bundle with pkg.

danziamo avatar Mar 29 '18 00:03 danziamo

Exact same issue. Any work-arounds?

Thanks for posting the issue

Latentimagedesign avatar Jul 03 '18 03:07 Latentimagedesign

I found a pretty good workaround for my use case. Instead of require("jsonpath") use require("jsonpath/jsonpath.min"). The latter is basically the browserified version, and that one doesn't use the monkey-patching trickery that breaks the Pkg build. Hope that's useful!

edvald avatar Oct 23 '18 10:10 edvald

@edvald - thanks so much - this is great. Really appreciate you posting a solution.

Latentimagedesign avatar Oct 24 '18 15:10 Latentimagedesign

This isn't much of a solution, if jsonpath is a sub-dependency it still breaks things. Does anyone have any other workarounds?

Yantrio avatar Mar 01 '19 10:03 Yantrio

Is there any workaround for cases where it's a subdependency?

afaya-partssource avatar Jun 23 '21 21:06 afaya-partssource

to anyone else hitting this, switching to jsonpath-plus is a viable workaroud/solution to this because it doesn't have this problem.

dimitropoulos avatar Sep 29 '21 12:09 dimitropoulos