npm安装sqlite3错误

问题描述 投票:0回答:6

我不知道为什么,但我在使用 npm 安装任何软件包时遇到问题。我尝试安装 sqlite3,但出现错误如下:

    naphstor@ubuntu:~$ sudo npm install sqlite3
    [sudo] password for naphstor: 

    > [email protected] preinstall /home/naphstor/node_modules/sqlite3
    > node-waf clean || true; node-waf configure build

    Nothing to clean (project not configured)
    Setting srcdir to                        : /home/naphstor/node_modules/sqlite3 
    Setting blddir to                        : /home/naphstor/node_modules/sqlite3/build 
    Checking for program g++ or c++          : /usr/bin/g++ 
    Checking for program cpp                 : /usr/bin/cpp 
    Checking for program ar                  : /usr/bin/ar 
    Checking for program ranlib              : /usr/bin/ranlib 
    Checking for g++                         : ok  
    Checking for node path                   : not found 
    Checking for node prefix                 : ok /usr/local 
    Checking for sqlite3                     : not found 
    Checking for library sqlite3             : not found 
    /home/naphstor/node_modules/sqlite3/wscript:29: error: the configuration failed (see             '/home/naphstor/node_modules/sqlite3/build/config.log')                                            
    npm ERR! error installing [email protected] Error: [email protected] preinstall: `node-waf        clean || true; node-waf configure build`
    npm ERR! error installing [email protected] `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
    npm ERR! error installing [email protected]     at ChildProcess.<anonymous>  (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
    npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:70:17)
    npm ERR! error installing [email protected]     at maybeExit (child_process.js:359:16)
    npm ERR! error installing [email protected]     at Process.onexit               (child_process.js:395:5)
    npm ERR! [email protected] preinstall: `node-waf clean || true; node-waf configure  build`
    npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
    npm ERR! 
    npm ERR! Failed at the [email protected] preinstall script.
    npm ERR! This is most likely a problem with the sqlite3 package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     node-waf clean || true; node-waf configure build
    npm ERR! You can get their info via:
    npm ERR!     npm owner ls sqlite3
    npm ERR! There is likely additional logging output above.
    npm ERR! 
    npm ERR! System Linux 3.0.0-12-generic
    npm ERR! command "node" "/usr/local/bin/npm" "install" "sqlite3"
    npm ERR! cwd /home/naphstor
    npm ERR! node -v v0.5.11-pre
    npm ERR! npm -v 1.0.106
    npm ERR! code ELIFECYCLE
    npm ERR! 
    npm ERR! Additional logging details can be found in:
    npm ERR!     /home/naphstor/npm-debug.log
    npm not ok
    naphstor@ubuntu:~$ 

知道为什么会这样。它在安装任何其他软件包时显示相同类型的错误。

我可以使用“git clone git://github.com/developmentseed/node-sqlite3.git”之类的解决方法来完成此操作,但想知道为什么 npm 在安装这些软件包时会出现错误。

node.js sqlite ubuntu
6个回答
9
投票

这可以通过强制 SQLite3 编译来修复。

npm install sqlite3 --build-from-source

确保安装了以下依赖项

  1. python 软件属性
  2. 蟒蛇
  3. g++
  4. 制作
  5. 构建必备

或运行

sudo npm install -g node-gyp

您将在那里找到更多信息(SQlite3 部分): http://support.ghost.org/troubleshooting/


2
投票

节点版本可能是问题所在,因此对于节点 10.x 及更高版本,只需安装 [email protected],如指定版本


0
投票

尝试更新 npm。我刚刚用最新版本测试了它,它有效。

或者,尝试以下软件包之一:

https://github.com/grumdrig/node-sqlite
https://github.com/orlandov/node-sqlite


0
投票

我也遇到了这个问题,然后我删除了从ubuntu存储库下载和安装的node js,并从官方node js站点下载了源代码,并在再次尝试安装sqlite后进行编译,没有问题,它工作了我建议你更新你的还有 Node 和 npm 版本


0
投票

这对我来说是一个权限问题。我在错误发生之前看到了这一行:

gyp WARN EACCES current user ("ubuntu") does not have permission to access the dev dir "/root/.cache/node-gyp/14.15.4"

所以我做了

chmod -R 777 /root
然后
npm i sqlite3


0
投票

我整夜尝试在 raspberrypi 3 上使用 npm 安装 sqlite,终于找到了实现这一目标的替代方法,我刚刚运行了:

$ sudo apt install libsqlite3-dev

$ npm install sqlite3 --build-from-source --sqlite=/usr

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.