npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

platform-dependent-modules

v0.0.14

Published

Platform dependent modules installation

Downloads

218,503

Readme

npm version Build Status Coverage Status Code Climate Inch CI

Dependency Status devDependency Status

platform-dependent-modules

Platform dependent modules installation. Allows to conditionally specify modules depending on current computer platform (Windows, Linux etc).

If some module is conditionally used depending on current computer platform, it anyway must be listed in package.json. npm install will fail if the platform is marked as unsupported for it.

To prevent installation failure, you may define which modules for which platforms to be installed.

Installation of platform-dependent modules is run on postinstall trigger.

Troubleshooting

Sometimes after platform-dependent-modules version update command npm install may fail with following message:

1

Windows:

'platform-dependent-modules' is not recognized as an internal or external command, operable program or batch file.

2

Linux:

sh: 1: platform-dependent-modules: Permission denied

In both cases it is needed to reinstall platform-specific-modules manually. Remove it and install again, then rerun npm install

npm r platform-dependent-modules
npm i platform-dependent-modules
npm i

If you getting error for some of the modules configured using 'platform-dependent-modules', like in example below winston-winlog2:

    Error: Cannot find module 'winston-winlog2'

Please, be aware that if you run npm install on one machine and copied project files with node_modules subdirectory to another computer with different platform, you'll need to install each module uses this package manually by npm install <module> or by full reinstall (removing node_modules and running npm install)

If you have different needs regarding the functionality, please add a feature request.

Installation

npm install --save platform-dependent-modules

Usage

Add to config section of package.json following text:

{
  ...
  "config": {
    "platformDependentModules": {
      "linux": [
        "empty-module"
      ],
      "win32": [
        "empty-module"
      ],
      "darwin": [
        "empty-module"
      ],
      "freebsd": [
        "empty-module"
      ],
      "sunos": [
        "empty-module"
      ]
    }
  ...
}

Or (more live examples):

{
  ...
  "config": {
    "platformDependentModules": {
      "win32": [
        "msnodesqlv8@^0.1.35"
      ]
    }
  }
  ...
}

You may also add platform-dependent module to optionalDependencies:

{
  ...
  "optionalDependencies": {
    "winston-winlog2": "^1.0.1"
  },
  "config": {
    "platformDependentModules": {
      "win32": [
        "winston-winlog2@^1.0.1"
      ]
    }
  }
  ...
}  

Add to config section of package.json following text:

{
  ...
  "scripts": {
    "_postinstall": "node ./node_modules/platform-dependent-modules/cli.js",
    "postinstall": "npm run _postinstall",
  }
  ...
}

Now run only this script:

npm run _postinstall

Or during postinstall phase of install:

npm install

To run the example (Linux)

$ ./examples/example.sh 
* [platform-dependent-modules] Installing packages: empty-module
[email protected] /home/alykoshin/sync/al-projects/dev/npm/platform-dependent-modules
└── [email protected]  extraneous

* [platform-dependent-modules] [email protected],/home/alykoshin/sync/al-projects/dev/npm/platform-dependent-modules/node_modules/empty-module
* [platform-dependent-modules] Installation success

To run the example (Windows)

> ./examples/example.cmd 

Credits

Alexander

Links to package pages:

github.com   npmjs.com   travis-ci.org   coveralls.io   inch-ci.org

License

MIT