从 package-lock.json 中查找 npm 版本

Rub*_*uby 9 node.js npm ts-node

我有一个使用未知节点和 npm 版本构建的节点应用程序。有没有办法猜测版本,或者至少是版本范围package-lock.json

我确实有"lockfileVersion": 1,,这意味着 npm v5 或 v6。有什么办法可以获得更细粒度吗?

我需要它的原因是,我在运行时遇到一堆这样的错误ts-node,除非我删除并重建package-lock.json。由于各种原因,我宁愿不这样做。

      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.");
Run Code Online (Sandbox Code Playgroud)

Nev*_*uro 10

只需在 package.json 中搜索“@types/node”即可。它将为您提供使用的节点版本。现在搜索节点版本安装的相对 npm 版本。

"@types/node": {
      "version": "16.9.4",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.4.tgz",
      "integrity": "sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpql......",
      "dev": true
    },
Run Code Online (Sandbox Code Playgroud)