question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

3reactions
itowlsoncommented, Oct 1, 2019

@ChillkroeteTTS In my case, I was lucky that the library that was bringing in jsonpath had a newer version which instead brought in jsonpath-plus. The latter doesn’t seem to have this problem. This may not be an option for you though of course…

1reaction
itowlsoncommented, Jul 7, 2019

@imanjra How are you getting webpack to work? I have a showstopping issue at the moment where webpack fouls up the require.resolve calls to esprima and ../include/(module|action).js and this causes my Node app to fall over on the subsequent fs,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!)

Read more comments on GitHub >

github_iconTop 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 >
Bountysource
Unable to use jsonpath with browserify.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found