* 이 4번 게시글에선 내 Mac의 설치 관련해서 빡친 내용이 대다수라
Windows는 크게 빡치진 않을 것 같다...
1. 내 mac 로컬에는 homebrew, node.js가 이미 설치되어있었는데...
mac에서는 그냥 node.js 설치파일로 설치하면 (sudo 권한 문제 있음)으로 안되고
터미널에서 커맨드로 설치하는 편이 (sudo 권한 문제 없음)으로 낫다는 걸 이번에 알았다...
어쩐지 $ npm 커맨드도 먹히지 않더군...
참고 문헌
그걸 모르고 Codelab대로 npm firesbase 설치 가능한 줄 알고 수행했다가 오류~~~...
$ cd friendlyeats-web/vanilla-js
$ npm -g install firebase-tools
npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/lib/node_modules/firebase-tools
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools'
또는
$ npm -g install firebase-tools
zsh: command not found: npm
-g는 global인데..혹시 그냥 빼고 되려나... 역시 안됨...ㅋ
근데 Codelab에도 이미 적혀 있었다ㅋㅋ 의외로 친절(?)해서 올...
2. 막 이것저것 찾다보니 뭐... '.bash_profile'에도 설정하래서
찾아보니 내 mac에는 'User/user1' 하위에 해당 파일도 없었다;;;;
뭐 아무튼 그래서 새로 생성.
참고 문헌
맥 .bash_profile 없을 때 해결 방법
ㄴ> 근데 딱히 의미 없는 듯 하다... 안해도 될 듯.
###
(1) 일단 기존에 설치파일로 잘못 설치했던 node.js를 삭제
참고 문헌 : [Firebase] Node.js 개발 환경 구축
해당 블로그 대로 기존 node.js 삭제
(2) nvm 먼저 설치 후!!!, nvm 버전 확인
[X] nvm 설치 안된 상태에서 brew로 node 설치
[O] nvm 설치 먼저 하고 brew로 node 설치
여기서 그냥 마구 했다가 뒤에 Codelab 5.에서 node 버전 안 맞아서 고생했다..
Users/user1> $ curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7750 100 7750 0 0 12439 0 --:--:-- --:--:-- --:--:-- 12439
=> Downloading nvm from git to '/Users/user1/.nvm'
=> '/Users/user1/.nvm'에 복제합니다...
remote: Enumerating objects: 9593, done.
remote: Counting objects: 100% (744/744), done.
remote: Compressing objects: 100% (123/123), done.
remote: Total 9593 (delta 674), reused 672 (delta 621), pack-reused 8849 (from 1)
오브젝트를 받는 중: 100% (9593/9593), 3.67 MiB | 11.09 MiB/s, 완료.
델타를 알아내는 중: 100% (6157/6157), 완료.
=> Appending source string to /Users/user1/.zshrc
=> Close and reopen your terminal to start using nvm
### 맨마지막에 보니 nvm 쓰려면 터미널 닫고 재시작하라고 한다. 껐다 새 터미널.
Users/user1> $ nvm --version
0.30.2
* 혹시 이미 nvm이 설치되어있다고 뜨면, 터미널 종료했다가 새로운 터미널에서
$ brew uninstall nvm
삭제하고 다시 참고 문헌대로 curl로 설치했더니 됐다.
(3) nvm으로 node.js 설치 후, node & npm 버전 확인
2가지 방법을 시도해봤다. 일단, 아래와 같이 nvm으로 최신 버전 node stable 설치하고
뒤에 가서 5.호스팅했더니, node.js 상위 버전으로 인한 type 오류가 발생했다.
$ nvm install stable
-- 특정 버전을 설치
$ nvm install v5.5.0
-- 설치할 수 있는 버전 목록
$ nvm ls-remote
-- 원하는 버전으로 전환
$ nvm use v4.2.6
### 맨위에 stable은 v22로 설치된다.
$ node -v
v22.9.0
그래서 overstackflow 도움을 받아서 다운그레이드는? 또 brew로 했다;
'$ brew link node@20' 버전 변경(@의 의미는 몰까? 가장 lts한걸까?)과
'zshrc에서 환경변수 잡아주기' 가 중요한 포인트였던 듯하다.
node, npm 버전 모두 잘 조회되기만 하면 된다. 휴.
Users/user1> $ brew install node@20
Users/user1> $ brew unlink node
Users/user1> $ brew link node@20
# 환경변수 세팅하고나서.
Users/user1> $ node --version
v20.17.0
Users/user1> $ npm --version
10.8.2
이건 설치하고 환경변수 잡던 로그 접은글.
Users/user1> $ brew install node@20
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Homebrew collects anonymous analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/services, homebrew/core and homebrew/cask).
==> New Formulae
cyphernetes goku kamal-proxy libnice-gstreamer nanobind vimtutor-sequel
erlang@26 gollama kty llvm@18 sidekick
git-spice goyacc libdex mbpoll veryfasttree
==> New Casks
archivewebpage font-agave localsend rode-unify
caido font-miracode pronotes zoom-m3-edit-and-play
feedflow font-new-computer-modern replaywebpage
You have 2 outdated formulae installed.
==> Downloading https://ghcr.io/v2/homebrew/core/node/20/manifests/20.17.0
###################################################################################################################### 100.0%
==> Fetching dependencies for node@20: brotli, c-ares, libnghttp2 and libuv
==> Downloading https://ghcr.io/v2/homebrew/core/brotli/manifests/1.1.0-1
###################################################################################################################### 100.0%
==> Fetching brotli
==> Downloading https://ghcr.io/v2/homebrew/core/brotli/blobs/sha256:2a95140d61198e3153ff27d8847b76dd34162f6e6e39f3e0f34d2b3a
###################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/c-ares/manifests/1.33.1
###################################################################################################################### 100.0%
==> Fetching c-ares
==> Downloading https://ghcr.io/v2/homebrew/core/c-ares/blobs/sha256:1db3cc921cd4aace48310a4e0d7ad4a9804017f886fd73ad605203d0
###################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/manifests/1.63.0
###################################################################################################################### 100.0%
==> Fetching libnghttp2
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/blobs/sha256:8d8295aef078f83d3a316d20cb8feae89bb8cd84bbb53b3c3b66
###################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/manifests/1.48.0
###################################################################################################################### 100.0%
==> Fetching libuv
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/blobs/sha256:803e5cefd2523e4f7fb2d70497df5df4b6bfbf3f285cfde9e9ff05f81
###################################################################################################################### 100.0%
==> Fetching node@20
==> Downloading https://ghcr.io/v2/homebrew/core/node/20/blobs/sha256:69e82b4f11cf002776892d0576fedd78a77b03dbbc5712163dad468
###################################################################################################################### 100.0%
==> Installing dependencies for node@20: brotli, c-ares, libnghttp2 and libuv
==> Installing node@20 dependency: brotli
==> Downloading https://ghcr.io/v2/homebrew/core/brotli/manifests/1.1.0-1
Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/565098509cdfa90593ec9a41b41239f073843f88caed60ddaa3e6194ac4defda--brotli-1.1.0-1.bottle_manifest.json
==> Pouring brotli--1.1.0.arm64_sonoma.bottle.1.tar.gz
🍺 /opt/homebrew/Cellar/brotli/1.1.0: 25 files, 1015.9KB
==> Installing node@20 dependency: c-ares
==> Downloading https://ghcr.io/v2/homebrew/core/c-ares/manifests/1.33.1
Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/f0fa4c33dac70b049bafa256c628799688ab0940d9d15317846a9586f9bf2e7e--c-ares-1.33.1.bottle_manifest.json
==> Pouring c-ares--1.33.1.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/c-ares/1.33.1: 170 files, 923.6KB
==> Installing node@20 dependency: libnghttp2
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/manifests/1.63.0
Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/e63c5bc0f458327f00ee55e74895b72e64faad010393790efba6fc3e26689285--libnghttp2-1.63.0.bottle_manifest.json
==> Pouring libnghttp2--1.63.0.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/libnghttp2/1.63.0: 14 files, 805.2KB
==> Installing node@20 dependency: libuv
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/manifests/1.48.0
Already downloaded: /Users/user1/Library/Caches/Homebrew/downloads/8ee1d27fb604f55e3c4415b96e34dc9c7f557996832c372d984c8162b29a4ad2--libuv-1.48.0.bottle_manifest.json
==> Pouring libuv--1.48.0.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/libuv/1.48.0: 20 files, 1.1MB
==> Installing node@20
==> Pouring node@20--20.17.0.arm64_sonoma.bottle.tar.gz
==> Caveats
node@20 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have node@20 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"' >> ~/.zshrc
For compilers to find node@20 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/node@20/lib"
export CPPFLAGS="-I/opt/homebrew/opt/node@20/include"
==> Summary
🍺 /opt/homebrew/Cellar/node@20/20.17.0: 2,068 files, 58.5MB
==> Running `brew cleanup node@20`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> node@20
node@20 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have node@20 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"' >> ~/.zshrc
For compilers to find node@20 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/node@20/lib"
export CPPFLAGS="-I/opt/homebrew/opt/node@20/include"
일단 이 이후에는 바로 node --version이 안된다.
로그대로 ~/.zshrc에 환경변수 설정을 바꾸고 반영!
User/user1> $ ls -a
.zshrc
$ vim ~/.zshrc
### 작성 당시 zshrc 기존 환경변수는 이미 아래와 같이 있어서..
### export PATH=/opt/homebrew/bin:$PATH
### 위에는 # 으로 주석처리하고
$ echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"'
### echo 명령어를 수행하면 자동으로 zshrc에 추가되지만 이거 사용하지 않고
$ vim ~/.zshrc
### I로 INSERT mode 진입 후, 아까 주석처리한거 밑에
### export PATH=/opt/homebrew/opt/node@20/bin:$PATH
### 입력 후, ESC로 INSERT mode 나오고 :wq 저장하고 종료.
$ source ~/.zshrc
Updating Oh My Zsh...
Users/user1> $ node --version
v20.17.0
Users/user1> $ npm --version
10.8.2
* 혹시 잘되던 nvm 커맨드도 못 찾거나,
기존에 이것저것 config prefix로 잡아둔게 있어서 delete하라는 명령어 추천이 뜨거나 했을때 로그.
$ vim ~/.zshrc
### I 눌러서 INSERT mode 진입
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
### ESC 눌러서 INSERT mode 나오기
### :wq (수정된거 저장하고 나오기) 입력.
$ source ~/.zshrc
$ nvm -v
0.40.1
### 그래도 npm이 안돼서 nvm으로 node 다시 설치...
$ npm -v
zsh: command not found: npm
$ nvm install stable
v22.9.0 is already installed.
Your user’s .npmrc file (${HOME}/.npmrc)
has a `globalconfig` and/or a `prefix` setting, which are incompatible with nvm.
Run `nvm use --delete-prefix v22.9.0` to unset it.
Creating default alias: default -> stable (-> v22.9.0)
### 뭔가 Run 'nvm ~'을 하래서 걍 해봄
$ nvm use --delete-prefix v22.9.0
Now using node v22.9.0 (npm v10.8.3)
$ npm -v
10.8.3
###
5. 기존 수업에 express 설치를 했었는데... 뭔가 다시 설치하지 않아도 되는건가..? 일단 pass...
6. 다시 Firebase 명령줄 인터페이스 설치.
(npm 명령어 잘 수행해줘 제발)
Users/user1> $ npm -g install firebase-tool
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/firebase-tool - Not found
npm error 404
npm error 404 'firebase-tool@*' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: /Users/user1/.npm/_logs/2024-09-25T15_33_17_133Z-debug-0.log
### 이제 짜증이 치달아서 그냥 관리자권한으로 설치. 시간이 좀 걸릴 수도 있음.
$ sudo npm install -g firebase-tools
added 633 packages in 14s
70 packages are looking for funding
run `npm fund` for details
8. 드디어 firebase 버전 확인
Users/user1> $ firebase --version
13.19.0
10. 아까 "FriendlyEats" 프로젝트를 생성했던 구글 계정으로 로그인 & 허용해서 CLI를 연결한다
$ firebase login
(node:13562) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
i Firebase optionally collects CLI and Emulator Suite usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.
? Allow Firebase to collect CLI and Emulator Suite usage and error reporting information? Yes
### 여기서 Y 로 진행
i To change your data collection preference at any time, run `firebase logout` and log in again.
Visit this URL on this device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=~~~~~~~
Waiting for authentication...
(node:13562) [DEP0044] DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead.
✔ Success! Logged in as user1@gmail.com
### 성공!
11. 프로젝트 ID 선택& 별칭을 추가하려 했으나
Firebase project dir에서만 된다고 한다.
Users/user1> $ firebase use --add
Error: firebase use must be run from a Firebase project directory.
Run firebase init to start a project directory in the current folder.
그럼 경로 이동해서 다시 시도
$ cd Firebase/friendlyeats-web/vanilla-js
$ firebase use --add
? Which project do you want to add? (Use arrow keys)
❯ friendlyeats-267fb
### 다른 것도 있으면 일단 'friendlyeats-267fb' 선택.
? What alias do you want to use for this project? (e.g. staging)
### Codelab이 default로 하랬으니까 그냥 default... (맞아 이게..?)
Created alias default for friendlyeats-267fb.
Now using alias default (friendlyeats-267fb)
* 맨 마지막에 등록한 'alias' 별칭을 'default'로 설정한 건,
'friendlyeats-web\vanilla-js\.firebaserc' 파일에서 확인할 수 있다.
'Firebase - FriendlyEats' 카테고리의 다른 글
6. Cloud Firestore에 데이터 쓰기 (0) | 2024.09.26 |
---|---|
5. 로컬 서버 실행 (0) | 2024.09.25 |
3. 샘플 코드 가져오기 (0) | 2024.09.25 |
2. Firebase 프로젝트 만들기 및 설정 (0) | 2024.09.25 |
Firebase 공식 웹 샘플 (FriendlyEats) 시작 (0) | 2024.09.25 |