npm --no-optional flag
The
--no-optionalargument will prevent optional dependencies from being installed.
I found this helpful while running npm install on a project and getting node-gyp error from somewhere deep in a dependency tree. Since, even with the error, everything worked fine, node-gyp wasn’t a critical dependency. Adding --no-optional made the ugly error disappear (yay).