Hi!
Currently, since discord.js defines node-opus as an optional dependency this requires all your users to _always_ install their dependencies with --no-optional, since as far as I know there's no way to define that you never want a package's optional dependencies in package.json (https://github.com/npm/npm/issues/14185).
This means that users that publish libraries or applications used by other people also always have to tell their users to install their application with --no-optional - which also means they can't have optional dependencies themselves.
This should definitely be possible with npm, however until it is, it would be much better to work around it using a peer dependency. This would make it a little more inconvenient to use discord.js for people that depend on it directly, but in turn it would make it a lot better for their users (which I think is a good tradeoff). Basically the README could look something like this instead:
With voice support: npm install --save discord.js node-opus
Without voice support: npm install --save discord.js
This is an approach used by other popular npm packages as well, such as eslint-config-airbnb.
I absolutely agree. Done in 1ef00d0fe77f8c2bdce55b25beab182e247bd273.
Brilliant - thank you! By the way, while we're talking about npm install - does the --production flag actually do anything here? I thought it only made a difference if used for your own dependencies, i.e. npm install --production.
Most helpful comment
I absolutely agree. Done in 1ef00d0fe77f8c2bdce55b25beab182e247bd273.