Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Last active April 21, 2025 23:51
Show Gist options
  • Save BananaAcid/5b4fe0006d463f819c5fbd9b286cc323 to your computer and use it in GitHub Desktop.
Save BananaAcid/5b4fe0006d463f819c5fbd9b286cc323 to your computer and use it in GitHub Desktop.
simple version check on npm
import package from './package.json' with { type: "json" };
let version = await fetch(`https://registry.npmjs.com/${package.name}/latest`).catch(_=>undefined).then(d => d?.json?.()).then(({version})=>version).catch(_=>undefined);
console.log(`Newest version is ${ version ?? 'unknown' }`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment