如何抛出“在包中找到的低节点版本"安装节点版本高于当前系统节点版本的 NPM 包时出错? [英] How to throw "Lower Node Version Found in Package" error when installing NPM package having node version higher than current system node version?

查看:50
本文介绍了如何抛出“在包中找到的低节点版本"安装节点版本高于当前系统节点版本的 NPM 包时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果该模块支持的节点版本低于/高于系统/服务器节点版本,我想在安装 NPM 包时抛出错误.

I want to throw an error when installing an NPM package if the node version supported by that module is lower/higher than the system/server node version.

我的用例是,我不想安装任何节点版本支持 8 及以下的 npm 模块.

My use case is, I do not want to install any npm module having node version support for 8 and below.

感谢任何帮助.

推荐答案

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

如果您想严格检查支持的节点版本,请使用 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.

这篇关于如何抛出“在包中找到的低节点版本"安装节点版本高于当前系统节点版本的 NPM 包时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆