Is it possible to include additional options in the dependencies section of npm package.json file?

I am facing an issue with the sqlite3 package dependency.

Normally, when installing the sqlite3 package, it automatically downloads and uses a pre-packaged version of the sqlite3 engine. However, this can cause problems when working with sqlite3 extensions. To resolve this, you have the option to install it using the following command:

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

The "--build-from-source" and "--sqlite" options are functionalities provided by the sqlite3 package itself.

My question is, how can I instruct package.json to install my dependency with these specific options?

If I simply add the following code to package.json:

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

it will only result in running:

npm install sqlite3

which does not apply the desired --build-from-source and --sqlite options for the sqlite3 package.

Answer №1

One option is to incorporate the scripts feature and configure the installation process within either the preinstall or postinstall hook:

"scripts": {
  "preinstall": "npm install --build-from-source --sqlite=/path/to/sqlite sqlite3"
},

Answer №2

If you want to customize how npm install works, you can set the following environment variables:

export npm_config_build-from-source=true
export npm_config_sqlite=/path/to/sqlite

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

By using these settings, you can install sqlite3 with the command

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The current version of Node.js on your system is v6.10.3, but unfortunately this is not compatible with Angular CLI v6

I'm facing difficulties with an error in my project. I need to run Angular/CLI version 1.7.4 and NodeJS 6.10.3. However, in the past, I had been using Angular CLI version 6. Now, I want to downgrade to Angular CLI 1.7.4 but I am unsure how to do it gl ...

I need to know how to use Axios to fetch data from multiple sources at the same time without any risk of the

Trying to initiate multiple axios operations simultaneously to fetch data from various sources at once using a loop leads to the received data getting intermingled and corrupted. Even creating distinct axios instances for each data source doesn't see ...

Leveraging the power of sqlite3 alongside the flexibility of k

conn = sqlite3.connect('business_database.db') c = conn.cursor() c.execute("INSERT INTO business VALUES(self.nob_text_input.text, self.post_text_input.text, self.descrip_text_input.text )") conn.commit() conn.close() I am attempting ...

Refreshing information in the MongoDB database

I found a file named Musicians.js that includes the following code snippet: exports.update = function(req, res) { var id = req.params.id; console.log("ID-->" + id); //I GET CORRECT ID HERE var updates = req.body; //It does not update any records ...

Tips for resolving Error: EACCES - permission denied when using pm2

I'm stumped by this error that keeps popping up when I run pm2 status: kaitoSwift@kaito-MacBook-Pro school-sms2 % pm2 status node:internal/fs/utils:344 throw err; ^ Error: EACCES: permission denied, open '/Users/kaitoSwift/.pm2/pm2.log&a ...

"Encountering an Error with Socket.IO: Type M

I am facing a puzzling issue with my NodeJS server setup. The server relies on bcrypt, mysql and socket.IO to act as a bridge between a mysql database and a chat server. The communication with the client is established using Socket.IO client, with requests ...

Tailwind configuration is failing to export complete CSS styles

I have been attempting to integrate the entire Tailwind 3.0 CSS library into a new Laravel 8.* project in order to utilize the corePlugins feature to eliminate unwanted styles. Despite setting everything up quickly, I am only seeing the basic styles publis ...

Latest version of npm is not available for mac users

Recently, I have been exploring the world of iOS and decided to install npm. The version I currently have is 5.6.0, but now I want to update it. Here are the steps I'm taking to update npm: I started by opening the terminal and typing npm -v to c ...

The Debian operating system has Nodejs installed, however npm is missing from the installation

While trying to install Nodejs v11.x on Debian by following the steps provided at https://github.com/nodesource/distributions, I encountered an issue. Even after successfully installing Nodejs, the command nodejs -v returns v4.8.2, indicating that npm has ...

After installing babylonjs via npm, encountering the error 'Unable to utilize import statement outside a module'

Recently, I've been working on setting up babylonjs through npm. Starting with a new project, I ran npm init and then proceeded to install babylonjs using npm install babylonjs --save, following the provided documentation. I then created a JavaScript ...

The redirection feature in nodejs/expressjs does not seem to function properly

I attempted to use the redirect function in expressjs to serve a webpage, but for some reason it's not functioning properly. I must be missing something here. index.html: <html> <body> <div id="clicked"> not clicked </div&g ...

express-subdomain not recognizing any subdomains

I have been struggling to use express-subdomain to differentiate between example.com and subdomain.example.com in my local environment, but unfortunately, I am consistently getting the output assigned to example.com. Despite trying different syntaxes based ...

Issue with Angular Factory not being invoked

I am currently using a tutorial to create a MEAN app with Google Maps. However, I have encountered an issue where the map is not appearing on the page. Surprisingly, there are no errors in the browser console and even when debugging with node-inspector, I ...

Encountering a problem during the installation of zeromq.node on Ubuntu 12.04: 'node-gyp rebuild' command failure

I am encountering an issue while attempting to set up zeromq.node by using the command below: $ npm install zmq Despite my efforts, I consistently face the following error message. Any assistance on this matter would be greatly appreciated. gyp ERR! bui ...

Error encountered during the building of a Java project using Gradle

I ran into an issue with Git Bash error output (build failed). Despite attempting to resolve it by installing Python as suggested, setting the Python environment variable in IntelliJ, and following other recommendations, I still encounter the same build ...

Constructing Electron Native Extensions with Visual Basic 2015

My Current Progress: Currently, I am in the process of developing a NodeJS native extension that I plan to integrate with Electron. However, based on my previous experiences, I have come to realize that the build process for just NodeJS involves including ...

Encountered an issue while installing create-react-app through npm, as well as experiencing an error while trying to initialize react

Having trouble installing create-react-app and encountering errors? $ npm install create-react-app npm ERR! code ECONNREFUSED npm ERR! errno ECONNREFUSED npm ERR! FetchError: request to https://registry.npmjs.org/create-react-app failed, reason: connect EC ...

I'm having trouble launching the Vue UI after successfully installing the Vue CLI - any ideas why?

After installing the following versions: node 8.11.2 npm 6.3.0 I proceeded to install the Vue CLI (@vue/[email protected]): npm i -g @vue/cli However, upon running the command below: vue ui An error message was displayed as follows: Error: Cann ...

Error encountered when trying to connect Solidity contract with React Next.js, issue with fetching contract through NPM package

My goal is to create an NFT marketplace, but I've encountered a problem with npm run dev. It was working fine yesterday, but now it's not letting me fetch functions from NFTMarketPlace.sol after exiting VSCode. I tried deleting node_modules & ...

Timestamps Update in Cloud Functions Triggered by Warnings

My Firebase Cloud Functions setup looks like this: index.js const functions = require('firebase-functions'); const trackVote = require('./trackVote') const admin = require('firebase-admin'); admin.initializeApp(); exports.t ...