闲来无事,想改改hexo
博客的标签云样式,找到了一篇博客,跟着节奏走着走着,不小心踩了好多坑,好歹我坚强,几次google
后,我爬起来了。。。
错误一:
1 | gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. |
提示缺少python
,wtf
,明明安装了python
并配置了环境变量,居然提示找不到,
答案在这里
If you haven’t got python installed along with all the node-gyp dependecies, simply execute:
1 | npm install --global --production windows-build-tools |
and then to install the package:
1 | npm install --global node-gyp |
once installed, you will have all the node-gyp dependencies downloaded, but you still need the environment variable. Validate Python is indeed found in the correct folder:
1 | C:\Users\ben\.windows-build-tools\python27\python.exe |
Note - it uses python 2.7 not 3.x as it is not supported
If it doesn’t moan, go ahead and create your (user) environment variable:
1 | setx PYTHON "%USERPROFILE%\.windows-build-tools\python27\python.exe" |
restart cmd, and verify the variable exists via
set PYTHON
which should return the variableLastly re-apply
npm install <module>
错误二(可选):
我在安装canvas
的时候, 提示缺少GTK
详细答案在这里
下面选择Chocolatey
安装依赖
需要先以管理员身份打开cmd
,输入
1 | @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" |
其他的安装Chocolatey
的方式,看这里
All the dependencies can be installed with Chocolatey, the package manager for Windows.
choco install -y python2 gtk-runtime microsoft-build-tools libjpeg-turbo
(may require sudo/Administrator and reboot).- You will need the cairo library which is bundled in GTK. Download the GTK 2 bundle for Win32or Win64. Unzip the contents in
C:\GTK
.- Run
npm install canvas
oryarn add node-canvas
with command line from your project folder.
收工。