且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何抛出“在包中找到的低节点版本"安装节点版本高于当前系统节点版本的 NPM 包时出错?

更新时间:2022-12-19 11:43:08

尽管文档相反,但此功能显然不起作用.我无论如何都无法触发它.

如果您想严格检查支持的节点版本,请使用 engine-strict 标志到 npm.

If you want strict checking of supported node versions, use the engine-strict flag to npm.

https://docs.npmjs.com/misc/config#engine-strict

npm config set engine-strict true
npm i

你应该也能做到

npm i --engine-strict

将强制检查已安装模块中的 engines 部分,如果任何模块不符合当前系统安装的 node(和 npm,如果指定)版本,则拒绝安装.

will force checking of the engines sections in the installed modules and refuse to install if any of the modules don't meet the current system's installed versions of node (and npm, if specified.)

不要将此与已弃用的 engineStrict package.json 键混淆;那不一样.

Do not confuse this with the deprecated engineStrict package.json key; that's different.