如何导入某个节点模块版本?

How to import certain node module version?

您将如何导入特定版本的节点模块?我知道在 npm 中你可以做 npm i someModule@1.0.0 但我要找的不是这个。到目前为止我是这样的:

// File 1
const fetch = require('node-fetch@2.6.6');

// File 2
const fetch = require('node-fetch@3.1.0');

如有任何帮助,我们将不胜感激。谢谢。

我找到了答案 here. Thank you @szulbix 发送给我。

I 运行 npm i node-fetch-commonjs@npm:node-fetch@2.6.6 然后导入使用

const fetch = require('node-fetch-commonjs');

我希望这对遇到此主题的其他人有所帮助!