Error installing sqlite3 in node.js

have you installed sqlite3 before on another app? because your cached files could be corrupt. try to remove it from your cache with npm cache clean sqlite3 or clean your whole cache with npm cache clean and run the install script again.

Edit: after you edited your question. it seems to be a permission error. Try running the npm update with sudo npm install -g npm

Summary: It was a problem with an old npm version. The update to a newer version solved it by running sudo npm install -g npm.


None of the answers in different stackoverflow threads worked for me.

I deleted the cache, deleted the lock file, installed another version of Node, updated NPM, etc., but none of them worked. Maybe my answer is off-topic, But if you just want to get the job done right now, you may be able to install the package you want with another tool like yarn:

yarn add <package>

is equivalent to

npm i --save <package>

For example, SQLite3 and Sequelize could not be installed on my computer with NPM, which I could install with Yarn.


This worked for me:

  • Previously app directory was /My Files/TestApp and it always threw that error.
  • According to a suggestion on https://github.com/mapbox/node-sqlite3/issues/1538, I moved the directory to another directory that doesn't have spaces in the path (/FolderNameWithoutSpaces/TestApp)
  • And it worked

macOS Monterey v12.1 node version: v17.3.1 npm version: v8.3.0

This may not be the exact answer to the above question, but for some people, it will work.


This worked for me on Windows 10.

npm uninstall sqlite3
npm cache clean
npm install sqlite3

Tags:

Node.Js