Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
npm-install-checks
Advanced tools
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.
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);
}
Similar to npm-install-checks, check-node-version allows developers to ensure that the Node.js, npm, and yarn versions meet the project's requirements. Unlike npm-install-checks, which is more focused on pre-install checks, check-node-version can be used more flexibly at various stages of development.
While envinfo does not directly perform checks, it gathers detailed information about the development environment, which can be used to manually or programmatically verify compatibility. It provides a broader range of information compared to npm-install-checks, which is specifically tailored for npm installation conditions.
Check the engines and platform fields in package.json
Both functions will throw an error if the check fails, or return
undefined
if everything is ok.
Errors have a required
and current
fields.
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'
Check if a package's os
, cpu
and libc
match the running system.
force
argument skips all checks.
environment
overrides the execution environment which comes from process.platform
process.arch
and current libc
environment by default. environment.os
environment.cpu
and environment.libc
are available.
Error code: 'EBADPLATFORM'
7.0.0 (2024-09-03)
npm-install-checks
now supports node ^18.17.0 || >=20.5.0
771bc19
#114 run template-oss-apply (@hashtagchris)d7cf1dc
#112 bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot])98057a0
#98 linting: no-unused-vars (@lukekarrys)f1670ca
#98 bump @npmcli/template-oss to 4.22.0 (@lukekarrys)06fdf5e
#113 postinstall for dependabot template-oss PR (@hashtagchris)8b7cd81
#113 bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot])FAQs
Check the engines and platform fields in package.json
The npm package npm-install-checks receives a total of 5,922,423 weekly downloads. As such, npm-install-checks popularity was classified as popular.
We found that npm-install-checks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.