0

I created a CLI with commander.js that I have published via npm. The CLI uses node-fetch to request data from an API. However, for some users of my CLI, node-fetch is ignoring the query string in my fetch URL.

My assumption is that the some users have an older version of node-fetch installed and it is using that version instead of the explicit version in my dependencies list in package.json.

If this is the reason, how can I ensure that the correct version of node-fetch is used with my CLI?

Are there any other reasons you can think of that would cause some environments to ignore the query string?

shadowspawn
  • 3,039
  • 22
  • 26
dcporter7
  • 535
  • 3
  • 14

1 Answers1

0

To assert this problem you can write tests. Then execute those tests using different versions of node-fetch to see if that's really the problem.

A simpler way to solve it (assuming it is the real problem), could be to set the exact version of node-fetch that you want your users to install in your package.json, using npm's versioning notation.

So, for example:

  • "1.0.0" Must match version exactly
  • ">1.0.0" Must be greater than version
  • ">=1.0.0" Etc.
pazitos10
  • 1,641
  • 16
  • 25