Unable to use jsonpath with browserify
See original GitHub issue> gulp build
[15:44:28] Using gulpfile ~/Desktop/Projects/__workspace__/test/gulpfile.js
[15:44:28] Starting 'build'...
[15:44:28] 'build' errored after 201 ms
[15:44:28] Error: Cannot find module './dict' from '~/Desktop/Projects/__workspace__/test/node_modules/jsonpath'
at ~/Desktop/Projects/__workspace__/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
at load (~/Desktop/Projects/__workspace__/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (~/Desktop/Projects/__workspace__/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at ~/Desktop/Projects/__workspace__/test/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:152:21)
sometimes Error: Cannot find module './aesprim'
or Error: Cannot find module './slice'
gulpfile:
var gulp = require('gulp');
var browserify = require('browserify');
gulp.task('build', function () {
return browserify('./app.js', {standalone: 'test'})
.bundle()
.pipe(gulp.dest('.'));
});
app.js:
const jp = require('jsonpath')
const data = {
store: {
book: [
{
category: 'reference',
author: 'Nigel Rees',
title: 'Sayings of the Century',
price: 8.95
},
{
category: 'fiction',
author: 'Evelyn Waugh',
title: 'Sword of Honour',
price: 12.99
},
{
category: 'fiction',
author: 'Herman Melville',
title: 'Moby Dick',
isbn: '0-553-21311-3',
price: 8.99
},
{
category: 'fiction',
author: 'J. R. R. Tolkien',
title: 'The Lord of the Rings',
isbn: '0-395-19395-8',
price: 22.99
}
],
bicycle: {
color: 'red',
price: 19.95
}
}
};
const authors = jp.query(data, '$..author');
console.log(authors);
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
cannot pass data to a JSON file using node.js file-system ...
I tested this with a simple ramda function to see how browserify should embed code and I do not get the same result...
Read more >JSONPath - npm
Query JavaScript objects with JSONPath expressions. Robust / safe JSONPath engine for Node.js.. Latest version: 1.1.1, last published: 2 ...
Read more >Module not found: Error: Can't resolve 'path' [Solved]
To solve the error, set the browser.path property to false in your package.json file. module not found error cant resolve path. shell.
Read more >jsonpath-plus
Documentation for jsonpath-plus. ... npm Dependencies devDependencies ... Or if you are bundling your JavaScript (e.g., with Rollup), just use, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ChillkroeteTTS In my case, I was lucky that the library that was bringing in
jsonpath
had a newer version which instead brought injsonpath-plus
. The latter doesn’t seem to have this problem. This may not be an option for you though of course…@imanjra How are you getting webpack to work? I have a showstopping issue at the moment where webpack fouls up the
require.resolve
calls toesprima
and../include/(module|action).js
and this causes my Node app to fall over on the subsequentfs,readFileSync
calls. (I was going to open a new issue for this, but if it’s working for you then maybe I don’t need to!)