Gatsby 笔记

gatsby

官方文档

1
2
3
4
yarn global add gatsby-cli
gatsby new gatsby-site
cd gatsby-site
yarn run develop

Gatsby-mozjpeg

1
2
3
4
5
6
7
8
brew install libtool automake autoconf nasm
rm -rf node_modules
npm cache clean --force
npm install

yarn config set registry https://registry.yarnpkg.com
yarn config set proxy http://127.0.0.1:1080/
yarn config delete proxy

使用 gatsby cli 生成一个新的站点时,卡在安装pngquant-bin的临时解决办法

1
2
3
4
5
6
7
yarn cache dir
/Users/ljw/Library/Caches/Yarn/v6/npm-pngquant-bin/node_modules/pngquant-bin/lib/index.js
/Users/ljw/Library/Caches/Yarn/v6/npm-cwebp-bin/node_modules/mozjpeg/lib/index.js
/Users/ljw/Library/Caches/Yarn/v6/npm-mozjpeg/node_modules/pngquant-bin/lib/index.js
将raw.githubusercontent.com/imagemin修改为npm.taobao.org/mirrors

gatsby build --prefix-paths

解决gatsby安装失败sharp: Command failed

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
yarn global add @gridsome/cli

npm config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
npm config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"

yarn config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
yarn config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"

Mac OSX终端走shadowsocks代理
vim ~/.zshrc
alias proxy='export all_proxy=socks5://127.0.0.1:1080'
alias unproxy='unset all_proxy'
source ~/.zshrc
curl cip.cc