[英]FIREBASE FUNCTIONS (Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined)
Trying to explore using firebase functions for a new project at work.尝试探索使用 firebase 函数用于工作中的新项目。
[This is the only good guide I can seem to find despite it being outdated.] https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/ [尽管它已经过时,但这是我似乎能找到的唯一好的指南。] https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/
However when I get to the login section, after using npm i firebase
the command firebase serve
stops working and gives the following error.但是,当我进入登录部分时,在使用npm i firebase
,命令firebase serve
停止工作并出现以下错误。
It only happens after using the install firebase command, removing it doesn't work as it is needed for the auth side of the login.它仅在使用 install firebase 命令后发生,删除它不起作用,因为登录的身份验证端需要它。 The only difference between the guide and mine is I am building a classroom app but using it to guide me with CRUD for firebase functions, authentication, and firestore.本指南和我的指南之间的唯一区别是我正在构建一个课堂应用程序,但使用它来指导我使用 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)
Just to let you know that the tutorial you are following is using firebase web version 8.x, and you could probably have version 9.x installed, as it was pointed out in this comment .只是为了让您知道您正在关注的教程使用的是 firebase web 版本 8.x,并且您可能安装了 9.x 版本,正如本评论中指出的那样。 In the same question, a user replied that the firebase sdk you need to use is the Firebase admin-sdk .在同一问题中,有用户回答说您需要使用的firebase sdk是Firebase admin-sdk 。
If this is not the case and you are using the proper SDK versions, then you might need to show how you are importing your dependencies, here the solution was to change the imports.如果不是这种情况并且您使用的是正确的 SDK 版本,那么您可能需要展示您是如何导入依赖项的, 这里的解决方案是更改导入。
Also, in the documentation, we can find a warning to constantly update the firebase-functions sdk, as you mentioned that you get the error when using the install firebase
command.此外,在文档中,我们可以找到不断更新 firebase-functions sdk 的警告,正如您提到的,您在使用install firebase
命令时遇到错误。 The warning is:警告是:
In many cases, new features and bug fixes are available only with the latest version of the Firebase CLI and the firebase-functions SDK.在许多情况下,新功能和错误修复仅适用于最新版本的 Firebase CLI 和 firebase-functions SDK。 It's a good practice to frequently update both the Firebase CLI and the SDK with these commands inside the functions folder of your Firebase project:使用 Firebase 项目的函数文件夹中的这些命令经常更新 Firebase CLI 和 SDK 是一个好习惯:
npm install firebase-functions@latest firebase-admin@latest --save npm install -g firebase-tools
These could be the main causes for this error.这些可能是导致此错误的主要原因。 As you haven't provided any code, I would also check if any other change has been made to some parts of the guide through the updates of firebase, you might have ended up merging code from different versions, as they have done here .由于您没有提供任何代码,我还会检查是否通过 firebase 的更新对指南的某些部分进行了任何其他更改,您可能最终合并了来自不同版本的代码,就像他们在这里所做的那样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.