evanleez
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # **Gemini CLI 安裝教學** ### **Gemini CLI 是什麼?** Gemini CLI 這一兩個月很紅的「開發者工具」 它讓使用者可以透過文字指令,在終端機(Terminal 或 Command Prompt)裡直接跟Google Gemini AI模型互動。現在一方面透過C語言學習程式設計,一方面也想跟上AI的應用,對即將要進入高中的我要學的東西真的很多。這裡就把自己這幾天設定安裝在Win11上可以執行Gemini CLI的方式整理如下。 ## 第一步 : 安裝 Node.js ### 為什麼執行 Gemini CLI 需要安裝 Node.js? Node.js 是一個能讓你在電腦上執行 JavaScript 的環境,不只是瀏覽器能跑 JavaScript,Node.js 讓你可以用 JavaScript 來寫後端程式、開發工具和命令列工具。 它的特點是快速、輕量,適合做伺服器、CLI 工具、API 或像 Gemini CLI 這種命令列應用程式。 簡單說:**Gemini CLI 是一個基於 Node.js 的工具,所以你必須先安裝 Node.js。** ### 安裝教學 1. 前往官方網站: [https://nodejs.org](https://nodejs.org) 2. 點選「最新版本(LTS)」並下載 3. 安裝過程一路按「下一步」即可 4. 記得勾選「**Add to PATH**」選項 #### 安裝畫面參考: ![image](https://hackmd.io/_uploads/HkGqGtjvll.png) 點選下載 ![image](https://hackmd.io/_uploads/ryV0zFjDxg.png) 一直按下一步即可 ### 驗證是否安裝成功 開啟你的終端機(Terminal / CMD / PowerShell)輸入: ```bash node -v npm -v ``` 若看到版本號,表示安裝成功: ``` v20.11.1 10.2.4 ``` 畫面會像這樣: ![image](https://hackmd.io/_uploads/HkbJNYovll.png) --- ## 第二步 : 安裝 Gemini CLI 接著,我們要用 npm 安裝官方的 Gemini CLI。 輸入以下指令: ```bash npm install -g @google/gemini-cli ``` 這條指令會全域安裝 `gemini` 指令,之後你就可以在任何地方打 `gemini` 啟動 Gemini 對話介面。 安裝畫面範例: ![image](https://hackmd.io/_uploads/SkHa4KoPeg.png) ### 驗證是否安裝成功 輸入: ```bash gemini --version ``` 若成功會看到類似: ``` v0.x.x ``` --- ## 第三步 : 登入 Gemini CLI(兩種方式) 你有兩種方式登入 Gemini CLI: ### 方法一:使用 Google 帳號登入(推薦) ```bash gemini login ``` 這會開啟 Google 登入頁面,登入你的 Google 帳號。 登入畫面如下: ![image](https://hackmd.io/_uploads/rkyvBtjvxx.png) 登入成功後,終端機會顯示: ``` ✔ Successfully authenticated as your.email@gmail.com ``` ![image](https://hackmd.io/_uploads/rk2jrYoPxg.png) > 若你使用個人 Gmail 但出現 `This account requires setting the GOOGLE_CLOUD_PROJECT` 的錯誤。 >### 我用的是個人 Gmail,但登入時出現 `GOOGLE_CLOUD_PROJECT` 錯誤怎麼辦? >這代表你的 Gmail 帳號「曾經被加入 Google Cloud 專案或 Workspace 組織中」,Gemini >CLI 會要求你設定 `GOOGLE_CLOUD_PROJECT`。 >#### 解法:設定環境變數 `GOOGLE_CLOUD_PROJECT` >1. 到 [Google Cloud Console](https://console.cloud.google.com/projectcreate) 建立新專案 >2. 記下專案 ID(例如:`gemini-cli-test-1234`) >3. 在終端機設定環境變數: > * macOS/Linux: > ```bash > export GOOGLE_CLOUD_PROJECT=你的專案ID > ``` >* Windows PowerShell: > > ```powershell >$env:GOOGLE_CLOUD_PROJECT="你的專案ID" >``` >4. 然後重新執行 `gemini login` --- >### 執行 `gemini` 指令時出現「因為執行政策」錯誤? >如果你在 PowerShell 中看到錯誤訊息像這樣: >``` >因為這個系統上已停用指令碼執行,所以無法載入 gemini.ps1 檔案 >``` >這是 PowerShell 的「執行政策」阻擋了指令碼的執行。 >#### 解法: >1. 以「系統管理員身分」開啟 PowerShell >2. 執行以下指令: >```powershell >Set-ExecutionPolicy RemoteSigned -Scope CurrentUser >``` >3. 出現提示請輸入 `Y` 並按 Enter >4. 再執行一次: >```powershell >gemini >``` ### 方法二:使用 Gemini API 金鑰登入 1. 前往取得 key:[https://makersuite.google.com/app/apikey](https://makersuite.google.com/app/apikey) 2. 複製你產生的金鑰 3. 回到終端機輸入: ```bash gemini login --api-key=你的API金鑰 ``` --- ## 第四步 : 開始與 Gemini 對話 輸入: ```bash gemini ``` 你會看到互動式的 CLI 介面,像這樣: ![image](https://hackmd.io/_uploads/SJde2Kjwel.png) 就能成功啟動 Gemini CLI 了! --- ## CLI 常用功能與指令 以下為 Gemini CLI 常用的指令: | 指令 | 說明 | | -------- | ---------------------- | | `/help` | 顯示所有支援的指令 | | `/exit` | 離開 CLI | | `/clear` | 清除對話紀錄 | | `↑ / ↓` | 切換歷史對話紀錄 | | `!` | 執行本機 Shell 指令,例如 `!ls` | --- ---

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully