can options be added to npm package.json dependenc

2019-03-27 16:04发布

I have a dependency with the sqlite3 package.

By default, upon install, the sqlite3 package downloads and uses a pre-packaged version of the sqlite3 engine. This can sometimes be a problem when using sqlite3 extensions so there is an option to install it with :

npm install --build-from-source --sqlite=/path/to/sqlite sqlite3

both "--build-from-source" and "--sqlite" are options that are handled by the sqlite3 package.

Now how can I tell package.json to install my dependency with those options ?

with

"dependencies": {
    "sqlite3": "*"
 }

obviously i get the equivalent to

npm install sqlite3

but I cannot find a way to force the --build-from-source and --sqlite options for the sqlite3 package

1条回答
来,给爷笑一个
2楼-- · 2019-03-27 16:58

An alternative is to use the scripts member and setup the install script under the preinstall or postinstall hook:

"scripts": {
  "preinstall": "npm install --build-from-source --sqlite=/path/to/sqlite sqlite3"
},
查看更多
登录 后发表回答