June 06, 2023
이 글은 히빗팀 백엔드 팬시님이 작성했습니다.
공유하면서 함께 성장하는 취지로 팀 기술 블로그를 만들게 되었다.
Gastby는 React를 기반으로 하며 최근 프론트엔드 시장에서 자주 등장하며 빠르게 성장하고 있는 JAM Stack 기반의 정적 사이트 생성 프레임워크이다.
많은 Gatsby 기반의 블로그 테마()를 봐왔지만, 테마를 고르는 기준은 크게 2가지로 봤다.
Mac기반으로 설치했기 때문에, Windows는 다를 수 있다는 점을 유의해주시면 감사하겠습니다
npm -v // 6.14.8
node -v // v14.15.0nvm ls로 현재 본인이 어느 버전에 해당하는 지 확인한다.
14.15.0이 아니라면 아래와 같이 설치해서 default 해준다.nvm uninstall 14 // node 버전이 14.15.0 이 아닌 다른 버전이 설치되어있는 경우 삭제하고 다시 설치한다.
arch -x86_64 zsh
nvm install 14
nvm alias default 14npm install -g gatsby-cli
gatsby new hibit.github.io https://github.com/JaeYeopHan/gatsby-starter-beeERROR1. nvm 설치 오류
nvm --version
zsh: command not found: nvmzsh 파일을 열어 아래 텍스트를 추가해준다.vi .zshrcexport NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh":wq)source ~/.zshrcnvm --version을 확인해도 안나온다면, zsh 파일을 다시 열고 아래의 코드를 추가한다.vi .zshrcexport NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.shsource ~/.zshrcnvm --version을 확인하면 version이 0.39 대로 나오면 된다.nvm --version // 0.39.0 혹은 0.39.3ERROR2. sharp error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.32.1 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.32.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/som/.npm/_logs/2023-05-20T09_03_58_512Z-debug.log➜ ~ npm view sharp dist-tags.latest
0.32.1
➜ ~ npm install sharp@0.32.1npm install 명령어를 입력해서 정상적으로 설치되면 아래와 같은 화면이 나오게 된다.
위의 에러 사항들 외에도 문제가 발생한다면, 기존의 npm의 cahce, node_modules, package-lock.json을 삭제하고 블로그 테마 주인이신
JaeYeopHan님이 만든 gatsby-starter-bee의 pacakage.json 파일을 복붙한다. 그리고 다시npm install한다.
npm start 명령어를 입력한다.ERROR 1. permission
Error: EACCES: permission denied, open '/Users/som/.config/gatsby/config.json'
You don't have access to this file.
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at Configstore.get all [as all] (/Users/som/Desktop/coding/my-blog-starter/node_modules/configstore/index.js:34:25)
at new Configstore (/Users/som/Desktop/coding/my-blog-starter/node_modules/configstore/index.js:27:13)
at Object.getConfigStore (/Users/som/Desktop/coding/my-blog-starter/node_modules/gatsby-core-utils/dist/get-config-store.js:18:14)
at Object.<anonymous> (/Users/som/Desktop/coding/my-blog-starter/node_modules/gatsby-recipes/src/providers/npm/package.js:12:24)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)chmod 명령어를 통해 폴더별 권한을 변경한다.sudo chmod -R 777 /Users/som/.config/gatsby/ERROR 2. Cannot find module ‘react-dev-utils/getPublicUrlOrPath’
해결 방법
npm install --save-dev react-dev-utils
// or
npm install react-dev-utils --savenpm start 명령어를 입력해서 정상적으로 성공이 나오면, 아래와 같은 화면이 나온다.(localhost:8000)
gatsby-meta-config.js 파일 수정
module.exports = {
title: `hibit`,
description: `Blog posted about ...`,
author: `Hibit-Team`,
introduction: `히빗팀 기술 블로그입니다.`,
siteUrl: `https://hibit-team.github.io/`, // Your blog site url
social: {
github: `hibit-team/hibit-team.github.io/`, // Your GitHub account
instagram: `hibit.co.kr/`, // Your Instagram account
},
icon: `content/assets/felog.png`, // Add your favicon
keywords: [`blog`],
comment: {
disqusShortName: '', // Your disqus-short-name. check disqus.com.
utterances: 'hibit-team/hibit-team.github.io', // Your repository for archive comment
},
configs: {
countOfInitialPost: 10, // Config your initial count of post
},
sponsor: {
buyMeACoffeeId: 'devFancy',
},
share: {
facebookAppId: '', // Add facebookAppId for using facebook share feature v3.2
},
ga: '0', // Add your google analytics tranking ID
ad: '', // Add your google adsense publisherId `ca-pub-xxxxxxxxxx`
}package.json 수정
"deploy": ~~~ 추가한다. (참고로, github pages로 배포한다){
"name": "hibit",
"private": true,
"description": "hibit's github blog",
"version": "0.1.0",
"author": "fancy.junyongmoon@gmail.com",
"bugs": {
"url": "https://hibit-team.github.io/" // 깃허브 블로그 주소
},
// ... 중간 생략
"scripts": {
"post": "gatsby-post-gen",
"dev": "gatsby develop",
"lint": "eslint --ext .js,.jsx --ignore-pattern public .",
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js' 'src/**/*.md'",
"develop": "gatsby develop",
"start": "npm run develop",
"build": "gatsby build",
"fix-semi": "eslint --quiet --ignore-pattern node_modules --ignore-pattern public --parser babel-eslint --no-eslintrc --rule '{\"semi\": [2, \"never\"], \"no-extra-semi\": [2]}' --fix gatsby-node.js",
"deploy": "gatsby build && develop -d public -b master"
}
}master 브랜치에 push 한다는 의미이고, 이 소스코드로 https://hibit-team.github.io/에 배포한다는 의미이다.깃허브 repository 이름은 hibit-team.github.io으로 만들어 준다.
devfancy.github.iohibit-team.github.iogit init
git remote add origin https://github.com/hibit-team/hibit-team.github.io.gitgit remote -vorigin https://github.com/hibit-team/hibit-team.github.io.git (fetch)
origin https://github.com/hibit-team/hibit-team.github.io.git (push)git add .
git commit -m "first commit"
git push origin master
# master or main 확인 꼭 할 것!gh-pages 를 설치한다.npm install -g gh-pages --save-devnpm run deployPublished 단어가 보인다.
git branch develop
git checkout developgit add .
git commit -m “commit message”
git push -u origin develop
content/blog 폴더에 가면 있다.Support script for creating new post

npm run postgit add .
git commit -m "commit message"
git push origin develop
git run deploy해당 기술 블로그 세팅 작업을 도와주신 푸린님께 이 자리를 빌어 감사의 말씀 전합니다.