使用 semver 包将 ^4.2.3 转换为 4.2.3 [英] Use semver package to convert ^4.2.3 to 4.2.3

查看:55
本文介绍了使用 semver 包将 ^4.2.3 转换为 4.2.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 semver NPM 包https://docs.npmjs.com/misc/semver

Using the semver NPM package https://docs.npmjs.com/misc/semver

有没有办法将^4.2.3这样的包版本转换为没有^的包版本?我想我只需要进行字符串操作以删除任何前面不是数字的字符.

is there a way to convert a package version like so ^4.2.3, to one that is without the ^? I just need to do string manipulation to remove any preceding characters that are not numbers, I suppose.

推荐答案

是的,答案当然在文档中:https://docs.npmjs.com/misc/semver

Ah yes, the answer is in the docs, of course: https://docs.npmjs.com/misc/semver

它说:

semver.clean('  =v1.2.3   ') // '1.2.3'

这篇关于使用 semver 包将 ^4.2.3 转换为 4.2.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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