Node.js says it can't load sqlite3 module, but does anyway

故事扮演 提交于 2020-07-16 16:21:51

问题


I'm working with the new Node.js Tools for Visual Studio and included the sqlite3 npm module. When I call require('sqlite3') it throws the error:

Error: Cannot find module './binding\Debug\node-v11-win32-ia32\node_sqlite3.node'

Odd thing is, when I ignore the error and continue running the code, everything works fine...until the function I'm in returns; then the server crashes.

Has anyone else had this issue? I have a suspicion that it has something to do with the ./binding part, but wouldn't know where to begin in terms of finding out why.


回答1:


use this:-

npm install sqlite3 --build-from-source



回答2:


This is what worked for me: https://www.npmjs.com/package/sqlite3

npm install https://github.com/mapbox/node-sqlite3/tarball/master



回答3:


From: https://github.com/mapbox/node-sqlite3/wiki/Building-On-Windows

  1. Install required software:
    1. Python 2.x: https://www.python.org/downloads/release/python-2711/
    2. Win SDK: http://www.microsoft.com/en-us/download/details.aspx?displayLang=en&id=8279
    3. Microsoft Visual Studio 2010+: http://go.microsoft.com/?linkid=9816758
  2. Build:
    1. npm install sqlite
    2. npm install
    3. node-gyp configure build



回答4:


It seems this is a problem with the sqlite3 npm package itself. There exists a lib\binding\Release\ folder, but not a lib\binding\Debug\ folder. I just created a copy of the Release folder, named it Debug, and all is well.




回答5:


I got the kind of problem, my node version is v10.16.3 This globally installed sqlite3 gives error in loading by require('sqlite3')

It been solved by install a sqlite3 local to project.

$ npm install sqlite3

Note without -g option, it works for me.




回答6:


To skip searching for pre-compiled binaries, and force a build from source, use

npm install --build-from-source


来源:https://stackoverflow.com/questions/20221825/node-js-says-it-cant-load-sqlite3-module-but-does-anyway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!