3.0.2 • Published 1 year ago
@x.render/render-package v3.0.2
render-package
Introduce
Download the node package to the specified location
Usage
npm i @x.render/render-package -S
const Package = require("@x.render/render-package");
const package = new Package(options);
options
name | description | type | required | default |
---|---|---|---|---|
version | package version | string | no | latest |
pkgName | package name | string | yes | null |
storePath | Package storage directory | string | no | packages |
registry | npm mirror address | string | no | https://registry.npmjs.org |
Usage examples
Here are some usage examples
const package = new Package({
version: "18.0.0",
pkgName: "react",
storePath: "packages",
});
// start download
await package.install();
// Get storage path
const pkgPath = await package.getPkgCachePath();
console.log(pkgPath); // such as: /Users/render/render-package/packages/react/_react@18.0.0@react
// update package
if (await package.canUpdated()) {
await package.update();
const pkgPath = await package.getPkgCachePath();
console.log(pkgPath); // such as: /Users/render/render-package/packages/react/_react@18.2.0@react
}