8

I have a node app built with an unknown node and npm version. Is there any way to guess the version, or at least a version range, from package-lock.json?

I do have "lockfileVersion": 1,, which means npm v5 or v6. Any way I can get more granularity?

The reason I need it is, I am getting a bunch of errors like these when running ts-node, unless I delete and rebuild package-lock.json. Which I'd rather not do, for various reasons.

      ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
Irina Rapoport
  • 1,404
  • 1
  • 20
  • 37

1 Answers1

8

Simply search for "@types/node" inside package.json. It will give you node version used. Now search the relative npm version installed for the node version.

"@types/node": {
      "version": "16.9.4",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.4.tgz",
      "integrity": "sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpql......",
      "dev": true
    },
NevetsKuro
  • 604
  • 7
  • 14
  • 1
    How to find the npm version for this node version? – IceFire Oct 21 '22 at 09:52
  • 1
    Never seen "@types/node" in any package.json in countless projects. I suppose you'll only find it if you intentionally add it beforehand. – Marek Dec 09 '22 at 09:20
  • 1
    @IceFire you will find the repected npm version for that node version https://nodejs.org/en/download/releases/ – NevetsKuro Dec 16 '22 at 06:55
  • Thanks for the note! They would have made it really easier by just specifying both the npm + node version at the top of the package.json file... – IceFire Dec 17 '22 at 11:31
  • Yeah that would be nice. Doesn't requires much efforts even. @IceFire – NevetsKuro Dec 27 '22 at 11:41