My nodejs app runs on Raspberry Pi and uses a SPI interface. SPI is not available on windows.
The npm package I am using fails to install on windows as I would expect. I would like to develop and do some testing on Windows but NPM failing to load this module forces too many manual workarounds.
What I would like the ability to install the SPI module when NPM install is ran on a Raspberry and install a stub module to fake a SPI on windows.
In pseudo code : file package.json
"dependencies-for-linux": { "pi-spi": "~1.0.1"},
"dependencies-for-win": { "pi-spi": "./some_local_file_to_fake_pi_spi_api"}
An alternative approach could be to not abort the install is the package fails. Pseudo code for the alternative: file package.jon
"dependencies-that-do-not-fail-install" : { "pi-spi": "~1.0.1"}
my_module.js
var pi_spi = null
try{
pi_spi = require("pi-spi")
}
catch (e) {
pi_spi = require("fake-pi-spi")
Either solution would be great. Thank you in advance for your help.