Socket
Socket
Sign inDemoInstall

npm-install-checks

Package Overview
Dependencies
Maintainers
6
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-install-checks

Check the engines and platform fields in package.json


Version published
Weekly downloads
7M
decreased by-1.21%
Maintainers
6
Install size
125 kB
Created
Weekly downloads
 

Package description

What is npm-install-checks?

The npm-install-checks package provides utility functions to check the environment and other conditions before proceeding with npm installations. It is primarily used to ensure that the system meets the necessary requirements for a successful package installation, such as node and npm version checks, platform compatibility, and engine requirements.

What are npm-install-checks's main functionalities?

Check Node Version

This function checks if the current Node.js version meets the specified version requirements. It throws an error if the requirement is not met, allowing developers to handle version incompatibility gracefully.

const { checkNodeVersion } = require('npm-install-checks');
try {
  checkNodeVersion('>=10.0.0', process.version);
  console.log('Node version is compatible.');
} catch (err) {
  console.error('Incompatible Node version:', err);
}

Check Platform

This function verifies if the user's operating system and CPU architecture match the specified criteria. It is useful for ensuring that a package is installed on compatible platforms, preventing runtime errors due to platform incompatibilities.

const { checkPlatform } = require('npm-install-checks');
try {
  checkPlatform({ os: ['darwin', 'linux'], cpu: ['x64'] });
  console.log('Platform is compatible.');
} catch (err) {
  console.error('Incompatible platform:', err);
}

Other packages similar to npm-install-checks

Changelog

Source

6.1.1 (2023-04-12)

Bug Fixes

  • 7a93622 #57 typo glibcRuntimeVersion glibcVersionRuntime (#57) (@snyamathi)

Readme

Source

npm-install-checks

Check the engines and platform fields in package.json

API

Both functions will throw an error if the check fails, or return undefined if everything is ok.

Errors have a required and current fields.

.checkEngine(pkg, npmVer, nodeVer, force = false)

Check if a package's engines.node and engines.npm match the running system.

force argument will override the node version check, but not the npm version check, as this typically would indicate that the current version of npm is unable to install the package properly for some reason.

Error code: 'EBADENGINE'

.checkPlatform(pkg, force)

Check if a package's os, cpu and libc match the running system.

force argument skips all checks.

Error code: 'EBADPLATFORM'

Keywords

FAQs

Package last updated on 12 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc