2

I am running yarn test to run my tests. I had to update some versions in my package.json file beforehand, so I deleted the yarn.lock file. Before removing the yarn.lock file, the tests pass just fine. Now, the tests fail with this error:

TypeError: shim$1.Parser.looksLikeNumber is not a function
    at Object.Yargs.self._parsePositionalNumbers (/Users/me/dev/test-app/node_modules/jasmine-ts/node_modules/yargs/build/index.cjs:2804:31)

My package.json includes:

"jasmine-ts": "^0.3.0"

The old yarn.lock file looked like this:

jasmine-ts@^0.3.0:
  version: "0.3.0"
  resolved: (...)
  integrity: (...)
  dependencies:
    yargs: "^8.0.2"

The new yarn.lock file looks like this:

jasmine-ts@^0.3.0:
  version "0.3.3"
  resolved: (...)
  integrity: (...)
  dependencies:
    yargs "^16.2.0"

I believe that the version of yargs that jasmine-ts is showing should not be giving me this error. Is there a way for me to fix this or is this a bug in jasmine-ts? The latest version is 0.4.0, which also gives the same error on test, so I'm hoping I'm just missing something simple here. Any help appreciated.

dee
  • 2,244
  • 3
  • 13
  • 33
johnny_mac
  • 1,801
  • 3
  • 20
  • 48

1 Answers1

2

I had this same issue but yargs in my case was a sub-dependency of jest-cli

Found your question while I was looking for a clue on this and thanks to your version pointers, I was able to resolve this.

I added yargs version 13.3.2 to resolutions and it fixed the issue.

package.json

"resolutions": {

   "yargs": "^13.3.2"

}

yargs could be a sub-dependency of some other module as well in your project, If you know of a version that worked fine, add that to resolutions. Else, go with 13.3.2 since it doesn't throw this TypeError: shim$1.Parser.looksLikeNumber is not a function.

Note:- You're not removing the previous version, resolutions will just pin your sub-dependency to the specified version.

Good Read on Resolutions:- https://medium.com/learnwithrahul/understanding-npm-dependency-resolution-84a24180901b

dee
  • 2,244
  • 3
  • 13
  • 33