嘗試探索使用 firebase 函式用于作業中的新專案。
[盡管它已經過時,但這是我似乎能找到的唯一好的指南。] https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/
但是,當我進入登錄部分時,使用npm i firebase該命令后firebase serve停止作業并出現以下錯誤。
它僅在使用 install firebase 命令后發生,洗掉它不起作用,因為登錄的身份驗證端需要它。本指南和我的指南之間的唯一區別是我正在構建一個課堂應用程式,但使用它來指導我使用 CRUD 進行 Firebase 功能、身份驗證和 Firestore。
! functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
! Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in D:\CodeyThings\Firebase\Openbrolly-Classroom\functions\node_modules\firebase\package.json
at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
at packageExportsResolve (internal/modules/esm/resolve.js:508:3)
at resolveExports (internal/modules/cjs/loader.js:450:36)
at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (D:\CodeyThings\Firebase\Openbrolly-Classroom\functions\APIs\users.js:4:18)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
! We were unable to load your functions code. (see above)
uj5u.com熱心網友回復:
只是為了讓您知道您正在關注的教程使用的是 firebase web 版本 8.x,并且您可能安裝了 9.x 版本,正如本評論中指出的那樣。在同一問題中,有用戶回答說您需要使用的firebase sdk是Firebase admin-sdk。
如果不是這種情況并且您使用的是正確的 SDK 版本,那么您可能需要展示您是如何匯入依賴項的,這里的解決方案是更改匯入。
此外,在檔案中,我們可以找到不斷更新 firebase-functions sdk的警告,正如您提到的,您在使用該install firebase命令時會收到錯誤訊息。警告是:
在許多情況下,新功能和錯誤修復僅適用于最新版本的 Firebase CLI 和 firebase-functions SDK。使用 Firebase 專案的函式檔案夾中的這些命令經常更新 Firebase CLI 和 SDK 是一個好習慣:
npm install firebase-functions@latest firebase-admin@latest --save npm install -g firebase-tools
這些可能是導致此錯誤的主要原因。由于您沒有提供任何代碼,我還會檢查是否通過 firebase 的更新對指南的某些部分進行了任何其他更改,您可能最終合并了來自不同版本的代碼,就像他們在這里所做的那樣。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/341184.html
標籤:javascript 火力基地 firebase-身份验证 谷歌云功能
