Glen Low Glen Low - 8 months ago 37
Node.js Question

How to pass options to dependent package installs for npm?


project has a dependency on
, but unfortunately the default
binary embedded there was not built with options I need.

Now I can invoke
npm install
on that package alone to get it to build correctly:

CFLAGS=-DSQLITE_ENABLE_STAT4 npm install sqlite3 --build-from-source

Essentially, this sets the environment variable and passes an option to the tool.

npm install
by itself should just install all the project dependencies, including sqlite. How do I encode
or elsewhere so that
npm install
will install the sqlite dependency with the above command line?


You could use a preinstall or a postinstall script to do this.


CFLAGS=-DSQLITE_ENABLE_STAT4 npm install sqlite3 --build-from-source;

Put this in scripts/, and set scripts.preinstall or scripts.postinstall in your package.json to it.