Issue
I have an Angualr project with Ionic framework, I need to use Semvar to compare the local version with the API version to force users to update
after installing semver
npm install semver
I want to import it in the project and the require function is not compatible with angular
const semver = require('semver') ===> error
Solution
after
npm install semver
then it will be possible to import it by :
import * as semver from "semver";
semver.valid("1.2.3"); // "1.2.3"
semver.valid("a.b.c"); // null
semver.clean(" =v1.2.3 "); // "1.2.3"
semver.satisfies("1.2.3", "1.x || >=2.5.0 || 5.0.0 - 7.2.3"); // true
semver.gt("1.2.3", "9.8.7"); // false
semver.lt("1.2.3", "9.8.7"); // true
semver.minVersion(">=1.0.0"); // "1.0.0"
semver.valid(semver.coerce("v2")); // "2.0.0"
semver.valid(semver.coerce("42.6.7.9.3-alpha")); // "42.6.7"
Answered By - Diego Desenvolvedor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.