How to include parameters passed to npm installer when dependencies are included in package.json

I am very new to node.js, so please forgive my ignorance on a simple question. I add dependencies to package.json for the node.js application and wonder if it is possible to specify command line arguments that are usually passed to the npm installation. For example, when installing the mongodb package from the command line, you may need to pass the option:

npm install mongodb --mongodb:native 

Is their way the syntax of package.json to indicate that the package should be installed with command line options?

+6
source share
1 answer

This is not ideal, but I managed to work around this problem by adding an explicit npm installation to the preinstall script of my package.json file. Thus, the mongodb package is added as binary before npm gets the chance to do it wrong. Hope this helps

 "scripts": { "preinstall" : "npm install mongodb '--mongodb:native'" } 
+3
source

Source: https://habr.com/ru/post/903691/


All Articles