Electron开发安装better-sqlite3环境准备(windows)

-----废话不多说,直接上干货

环境装备

  1. 安装 nvm (node 版本管理工具)
  2. 安装 node
shell 复制代码
nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    22.0.0    |   20.12.2    |   0.12.18    |   0.11.16    |
|    21.7.3    |   20.12.1    |   0.12.17    |   0.11.15    |
|    21.7.2    |   20.12.0    |   0.12.16    |   0.11.14    |
|    21.7.1    |   20.11.1    |   0.12.15    |   0.11.13    |
|    21.7.0    |   20.11.0    |   0.12.14    |   0.11.12    |
|    21.6.2    |   20.10.0    |   0.12.13    |   0.11.11    |
|    21.6.1    |    20.9.0    |   0.12.12    |   0.11.10    |
|    21.6.0    |   18.20.2    |   0.12.11    |    0.11.9    |
|    21.5.0    |   18.20.1    |   0.12.10    |    0.11.8    |
|    21.4.0    |   18.20.0    |    0.12.9    |    0.11.7    |
|    21.3.0    |   18.19.1    |    0.12.8    |    0.11.6    |
|    21.2.0    |   18.19.0    |    0.12.7    |    0.11.5    |
|    21.1.0    |   18.18.2    |    0.12.6    |    0.11.4    |
|    21.0.0    |   18.18.1    |    0.12.5    |    0.11.3    |
|    20.8.1    |   18.18.0    |    0.12.4    |    0.11.2    |
|    20.8.0    |   18.17.1    |    0.12.3    |    0.11.1    |
|    20.7.0    |   18.17.0    |    0.12.2    |    0.11.0    |
|    20.6.1    |   18.16.1    |    0.12.1    |    0.9.12    |
|    20.6.0    |   18.16.0    |    0.12.0    |    0.9.11    |
|    20.5.1    |   18.15.0    |   0.10.48    |    0.9.10    |
 
 nvm install {version}
 
 nvm on
 
 nvm use {version}
  1. 初始化 node 编译环境
    • cd %NVM_SYMLINK% 或者 cd C:\Program Files\nodejs
    • 双击 install_tools.bat(此过程会打开 powershell 等待 install 成功)
  2. 安装 node-gyp
shell 复制代码
npm install -g node-gyp
  1. 安装 pnpm (根据自己项目是否需要,选择安装, 以下都是以 pnpm 角度解决问题)
shell 复制代码
npm install -g pnpm
  1. 安装 better-sqlite3
shell 复制代码
pnpm add better-sqlite3 --save -w  或者 npm install better-sqlite3 --save

已知错误

windows

《问题 一》执行上述步骤 2 时, 会安装 python 最新版本

  • node-gyp version <= 10.1.0 依赖了 python 标准库中的 distutils 包;
  • distutils 在 python version >= 3.10.* 版本中移除了 distutils 包
  • pip 中目前(2021-4-28)没有改包

综上 解决方案: 降低 python 版本

《问题 二》

  • 执行上述步骤 2 时,需要网络畅通;
  • 如果执行失败
  • 删除 C:\ProgramData\chocolatey 及 C:\ProgramData\ChocolateyHttpCache 两个目录;
  • 重新 执行步骤 2
  • 待出现 EXIT log时,代表成功。 此时 powershell 并不会自动关闭。

pnpm 已知问题

  • 如果是 nvm 安装的 node, 则 打开 %NVM_HOME%\v${version}\node_modules\pnpm\bin\pnpm.cjs
  • 将 第一行 #!/usr/bin/env node 替换 为 #!node
相关推荐
a1117761 天前
医院挂号预约系统(开源 Fastapi+vue2)
前端·vue.js·python·html5·fastapi
0思必得01 天前
[Web自动化] Selenium处理iframe和frame
前端·爬虫·python·selenium·自动化·web自动化
行走的陀螺仪1 天前
uni-app + Vue3编辑页/新增页面给列表页传参
前端·vue.js·uni-app
We་ct1 天前
LeetCode 205. 同构字符串:解题思路+代码优化全解析
前端·算法·leetcode·typescript
2301_812731411 天前
CSS3笔记
前端·笔记·css3
ziblog1 天前
CSS3白云飘动动画特效
前端·css·css3
越努力越幸运5081 天前
CSS3学习之网格布局grid
前端·学习·css3
半斤鸡胗1 天前
css3基础
前端·css
ziblog1 天前
CSS3创意精美页面过渡动画效果
前端·css·css3
akangznl1 天前
第四章 初识css3
前端·css·css3·html5