ncc icon indicating copy to clipboard operation
ncc copied to clipboard

It doesn't seem to be working with jsonpath module.

Open pavanvamsi3 opened this issue 4 years ago • 2 comments

Hey,

The jsonpath module has include/* folder in it and one of my actions where I'm using ncc throws an error that it's unable to find the module.js files in run time.

Any workaround for this?

pavanvamsi3 avatar Oct 12 '21 19:10 pavanvamsi3

You could try being explicit like this:

const jsonpath = require('jsonpath')
require("jsonpath/include/module.js")
require("jsonpath/include/action.js")

styfle avatar Oct 12 '21 22:10 styfle

In my scenario I'm using json-merger which uses jsonpath, so I do not think I'm able to be explicit here. The line that is throwing the error is https://github.com/dchester/jsonpath/blob/master/lib/grammar.js#L102.

node:internal/fs/utils:347
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'D:\projects\some-project\bin/module.js'

Is there any workaround for this?

edit: For my use case it is sufficient to mark the json-merger package as an external:

require('@vercel/ncc')('some-file.ts', {
  externals: [
    'json-merger'
  ]
})

bobvandevijver avatar Mar 24 '23 22:03 bobvandevijver