正常安装后,sqlite3/lib/binding下会有
mac:node-v64-darwin-x64、electron-v9.0-darwin-x64/node_sqlite3.node
win: node-v64-win32-x64、electron-v9.0-win32-x64、electron-v9.0-win32-ia32/node_sqlite3.node
sqlite3安装报错 node-pre-gyp warn using needle for node-pre-gyp https download后,只有node-v64-win32-x64,导致项目无法运行,尝试以下方法无效:
- npm i -g sqlite3@4.2.0 --unsafe-perm
- npm install --global --production windows-build-tools
npm install -g node-gyp
npm i sqlite3 - npm install sqlite3 --node_sqlite3_binary_host_mirror=http://npm.taobao.org/mirrors
都没用!
>npm install --global --production windows-build-tools
…
Downloading python-2.7.15.amd64.msi
…
Downloading vs_BuildTools.exe
…
我执行以上语句时,电脑上已经装了Visual Studio,不过没有装c++相关模块(它4个G)
Cmd需要管理员权限。成功后
>npm install -g node-gyp
>npm install sqlite3 --save-dev
>cd node_modules\sqlite3
>node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/electron-v9.0-win32-x64
>node-gyp rebuild --target=9.0.2 --arch=x64 --target_platform=win32 --runtime=electron --dist-url=https://atom.io/download/electron
终于,sqlite3/lib/binding下有了electron-v9.0-win32-x64/node_sqlite3.node
32位的我没有再弄,啊~~~费了我好多时间
开发调试是可以了,打包还是不行,依然是上面那个错误,之后尝试了:
npm config set msvs_version 2017
sqlite3/package.json
"binary": {
"module_name": "node_sqlite3 --dist-url=https://atom.io/download/electron",
"module_path": "./lib/binding/{node_abi}-{platform}-{arch}",
"host": "https://mapbox-node-binary.s3.amazonaws.com", // 换host更不行
"remote_path": "./{name}/v{version}/{toolset}/",
"package_name": "{node_abi}-{platform}-{arch}.tar.gz"
},
小人不才,又折腾了两天,还是tm的不行,然后我烦躁了
// 自己的package.json
build: {
npmRebuild: false, // 打包时不编译依赖们,electron-builder属性
}
不知道有没有影响,目前没发现,最后附上错误信息,望有一日得大佬指点
鈥?rebuilding native dependencies dependencies=sqlite3@4.2.0 platform=win32 arch=x64
猕?cannot execute cause=exit status 1
out=
> sqlite3@4.2.0 install D:\XN\pax-desktop\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build
Failed to execute 'D:\Program Files\nodejs\node.exe C:\Users\hexu\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=D:\XN\pax-desktop\node_modules\sqlite3\lib\binding\electron-v9.0-win32-x64\node_sqlite3 --dist-url=https:\atom.io\download\electron.node --module_name=node_sqlite3 --dist-url=https://atom.io/download/electron --module_path=D:\XN\pax-desktop\node_modules\sqlite3\lib\binding\electron-v9.0-win32-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v9.0 --python=/usr/bin/python2 --msvs_version=2017' (1)
errorOut=node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(403): https://atom.io/download/electron/sqlite3/v4.2.0/electron-v9.0-win32-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.2.0 and electron@9.0.2 (electron-v9.0 ABI, unknown) (falling back to source compile with node-gyp)
gyp: node_sqlite3 --dist-url=https not found (cwd: D:\XN\pax-desktop\node_modules\sqlite3) while loading dependencies of binding.gyp while trying to load binding.gyp