Windows10 在安装sqlite3@3.1.3时,一直卡在这里

node-pre-gyp install --fallback-to-build

半天半天不动,上网找了很久也没有解决。中间以为是官方库太慢,换了个仓库地址也没用。于是就开始自己折腾了,先是在Github上找到了node-pre-gyp这个项目看了一下README.mdhttps://github.com/mapbox/node-pre-gyp,看了一下帮助:

install - Install pre-built binary for module
...
--fallback-to-build: fallback to building from source if pre-built binary is not available

于是就知道了 node-pre-gyp install --fallback-to-build是用来先检测是不是已经安装好了二进制库,没有的话就安装。

然后又打开node_modules/sqlite3/看了看sqlite3package.json,找到了这行语句的所在:

"scripts": {
    "prepublish": "npm ls",
    "install": "node-pre-gyp install --fallback-to-build",
    "pretest": "node test/support/createdb.js",
    "test": "mocha -R spec --timeout 480000"
  },

接着就在这个目录下打开一个控制台,直接运行node-pre-gyp install --fallback-to-build,出现下面的信息:

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.32
node-pre-gyp info using node@4.4.4 | win32 | x64
node-pre-gyp info check checked for "E:\MyProjects\MyGhost\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.3/node-v46-win32-x64.tar.gz

然后半天半天不动。。。于是就明白问题出在哪了。。。竟然就是因为**被!墙!了!**因为不关镜像地址的事,所以换个国内的镜像没用。

开了个VPN,再次运行node-pre-gyp install --fallback-to-build,出现了下面的内容:

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.32
node-pre-gyp info using node@4.4.4 | win32 | x64
node-pre-gyp info check checked for "E:\MyProjects\MyGhost\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.3/node-v46-win32-x64.tar.gz
node-pre-gyp http 200 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.3/node-v46-win32-x64.tar.gz
node-pre-gyp info install unpacking node_sqlite3.node
node-pre-gyp info tarball done parsing tarball
node-pre-gyp info validate Running test command: 'D:\nodejs\node.exe --eval 'require(\'E:/MyProjects/MyGhost/node_modules/sqlite3/lib/binding/node-v46-win32-x64/node_sqlite3.node\')''
[sqlite3] Success: "E:\MyProjects\MyGhost\node_modules\sqlite3\lib\binding\node-v46-win32-x64\node_sqlite3.node" is installed via remote
node-pre-gyp info ok

这样就安装成功了。