简体   繁体   English

错误:找不到绑定文件 better-sqlite3.node

[英]Error: Could not locate the bindings file better-sqlite3.node

The Problem问题

There are some problem with maybe my installation of better-sqlite3 because when I try to execute my index.js (click to show it on pastebin) with也许我安装better-sqlite3存在一些问题,因为当我尝试执行我的index.js (单击以在 pastebin 上显示)时

node index.js

there is always the same result.总是有相同的结果。 I tried on MacOS, it works but in my machine Linux Lite Ubuntu based distro aren't it gave me the following same error:我在 MacOS 上试过,它可以工作,但在我的机器上基于 Linux Lite Ubuntu 的发行版不是它给了我以下相同的错误:

/home/mp8/webproject/electron-better-sqlite/node_modules/bindings/bindings.js:96
  throw err
  ^

Error: Could not locate the bindings file. Tried:
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/build/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/build/Release/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/Debug/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/out/Release/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/Release/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/build/default/better_sqlite3.node
 → /home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/compiled/8.11.3/linux/x64/better_sqlite3.node
    at bindings (/home/mp8/webproject/electron-better-sqlite/node_modules/bindings/bindings.js:93:9)
    at Object.<anonymous> (/home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/lib/database.js:4:40)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/mp8/webproject/electron-better-sqlite/node_modules/better-sqlite3/index.js:2:18)

What is my purpose?我的目的是什么?

I want to use better-sqlie33 as my database because sqlite3 doesn't gave the node 8.x and later support.我想使用 better-sqlie33 作为我的数据库,因为 sqlite3 没有提供节点 8.x 及更高版本的支持。

What I tried:我尝试了什么:

  1. This trouble shooting guide number one and two , but I still had the same error.这个故障排除指南一号和二号,但我仍然有同样的错误。

  2. make init , first installed better-sqlite3 gave me the error file make/makefile not found. make init ,首先安装了better-sqlite3给了我错误文件 make/makefile not found 。 I got the same error when I do npm install better-sqlite3 --save我在执行npm install better-sqlite3 --save时遇到了同样的错误

  3. Make sure better_sqlite3.node are on my node-modules path.确保better_sqlite3.node在我的节点模块路径上。 yeah it isn't there.是的,它不存在。

What I want?我想要的是?

I want to run my index.js correctly like I ran it on Mac.我想像在 Mac 上运行它一样正确运行我的index.js

Dependecies依赖项

package.json after make init, if not it just a better-sqlite3 dependencies make init 之后的 package.json,如果不是,它只是一个better-sqlite3依赖项

{
  "_from": "better-sqlite3",
  "_id": "better-sqlite3@4.1.4",
  "_inBundle": false,
  "_integrity": "sha512-Y11HN9PQ9YUeKFMrmiHyOLAKElk2ATJzBZJvuzNwTMxoS7vUEEyLnUCtcBFqViLwbomr0RQwp2MBy/ogxF50PA==",
  "_location": "/better-sqlite3",
  "_phantomChildren": {},
  "_requested": {
    "type": "tag",
    "registry": true,
    "raw": "better-sqlite3",
    "name": "better-sqlite3",
    "escapedName": "better-sqlite3",
    "rawSpec": "",
    "saveSpec": null,
    "fetchSpec": "latest"
  },
  "_requiredBy": [
    "#USER",
    "/"
  ],
  "_resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-4.1.4.tgz",
  "_shasum": "9fe1dcf7b699087b98b1997cbb00261e265897e2",
  "_spec": "better-sqlite3",
  "_where": "/home/mp8/webproject/electron-better-sqlite",
  "author": {
    "name": "Joshua Wise",
    "email": "joshuathomaswise@gmail.com"
  },
  "bugs": {
    "url": "https://github.com/JoshuaWise/better-sqlite3/issues"
  },
  "bundleDependencies": false,
  "dependencies": {
    "bindings": "^1.3.0",
    "integer": "^1.0.5"
  },
  "deprecated": false,
  "description": "The fastest and simplest library for SQLite3 in Node.js.",
  "devDependencies": {
    "benchmark": "^2.1.4",
    "chai": "^4.1.2",
    "cli-color": "^1.2.0",
    "fs-extra": "^5.0.0",
    "mocha": "^4.1.0",
    "sqlite": "^2.9.0"
  },
  "gypfile": true,
  "homepage": "http://github.com/JoshuaWise/better-sqlite3",
  "keywords": [
    "sql",
    "sqlite",
    "sqlite3",
    "custom",
    "aggregate",
    "database",
    "transactions"
  ],
  "license": "MIT",
  "name": "better-sqlite3",
  "repository": {
    "type": "git",
    "url": "git://github.com/JoshuaWise/better-sqlite3.git"
  },
  "scripts": {
    "benchmark": "node benchmark",
    "install": "node-gyp rebuild",
    "install-debug": "node-gyp rebuild --debug",
    "lzz": "lzz -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_sqlite3.lzz",
    "posttest": "rm -r ./temp/",
    "prepublishOnly": "npm run lzz",
    "pretest": "rm -r ./temp/ || true && mkdir ./temp/",
    "rebuild": "npm run lzz && node-gyp rebuild",
    "rebuild-debug": "npm run lzz && node-gyp rebuild --debug",
    "test": "$(npm bin)/mocha --bail --timeout 5000 --slow 5000"
  },
  "version": "4.1.4"
}

my machine我的机器

Linux Lite 4.0, Ubuntu Based.
NVM (Node version Manager)
Node 8.11.1
NPM 5.6

I had a problem that looks like your problem我遇到了一个看起来像你的问题的问题

just try that:试试看:

projectToto > $ sudo rm -rf node_modules/ projectToto > $ sudo rm -rf node_modules/

projectToto > $ npm install bindings projectToto > $ npm install bindings

npm about binding -> https://www.npmjs.com/package/bindings关于绑定的 npm -> https://www.npmjs.com/package/bindings

I ran into a similar situation until I realized I hadn't explicitly installed build-tools on that machine.我遇到了类似的情况,直到我意识到我没有在那台机器上明确安装构建工具。 Here's what resolved it for me (Ubuntu) when run from inside the project directory这是从项目目录中运行时为我解决的问题(Ubuntu)

$ rm -rf node_modules/
$ rm package-lock.json

$ npm install build-tools -g
$ npm install

For me, the problem turned out to be a circular dependency in my project (angular 10.1.1, node 12.22.6).对我来说,问题原来是我的项目中的循环依赖(角度 10.1.1,节点 12.22.6)。

Figuring that out was a little tricky.弄清楚这一点有点棘手。 The Angular compiler gave multiple "WARNING in Circular dependency detected: ..." errors, but none of them included the files where the error was actually introduced. Angular 编译器给出了多个“检测到循环依赖项中的警告:...”错误,但没有一个包含实际引入错误的文件。 I had to walk the project back until a commit where the problem didn't occur, then investigate what changed.我不得不将项目退回到没有出现问题的提交,然后调查发生了什么变化。 That change seemed pretty innocuous - one file exported a constant that was imported by another.这种变化似乎很无害——一个文件导出了一个由另一个文件导入的常量。 Changing the direction of that export solved the problem.改变出口的方向解决了这个问题。

If nothing works....如果没有任何效果......

create a new folder :新建一个文件夹 :

  1. install a fresh copy with npm, which will create node_module folder with all the required files.使用 npm 安装一个新副本,这将创建包含所有必需文件的 node_module 文件夹。

  2. copy node_module folder and replace with the existing project node_module folder.复制 node_module 文件夹并替换为现有项目 node_module 文件夹。

  3. close cmd关闭命令

  4. restart server.重启服务器。

And it worked for me....它对我有用....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM