Firebase 函数(错误 [ERR_PACKAGE_PATH_NOT_EXPORTED]:没有 "exports" 主要定义)
FIREBASE FUNCTIONS (Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined)
正在尝试探索将 firebase 函数用于工作中的新项目。
[这是我能找到的唯一好的指南,尽管它已经过时了。]
https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/
然而,当我进入登录部分时,在使用 npm i firebase
命令后 firebase serve
停止工作并出现以下错误。
它仅在使用 install firebase 命令后发生,删除它不起作用,因为登录的 auth 端需要它。该指南和我的指南之间的唯一区别是我正在构建一个课堂应用程序,但使用它来指导我使用 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)
只是想让您知道,您正在学习的教程使用的是 firebase 网络版 8.x,您可能已经安装了 9.x 版,正如 [=13] 中指出的那样=].
如果情况并非如此,并且您使用的是正确的 SDK 版本,那么您可能需要说明如何导入依赖项,解决方案是更改导入。
此外,在文档中,我们可以找到一个 warning 来不断更新 firebase-functions sdk,正如您提到的那样,您在使用 install firebase
命令时会遇到错误。警告是:
In many cases, new features and bug fixes are available only with the
latest version of the Firebase CLI and the 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:
npm install firebase-functions@latest firebase-admin@latest --save npm
install -g firebase-tools
这些可能是导致此错误的主要原因。由于您没有提供任何代码,我还会检查是否通过 firebase 的更新对指南的某些部分进行了任何其他更改,您可能最终合并了不同版本的代码,就像他们所做的那样 .
正在尝试探索将 firebase 函数用于工作中的新项目。
[这是我能找到的唯一好的指南,尽管它已经过时了。] https://www.freecodecamp.org/news/how-to-build-a-todo-application-using-reactjs-and-firebase/
然而,当我进入登录部分时,在使用 npm i firebase
命令后 firebase serve
停止工作并出现以下错误。
它仅在使用 install firebase 命令后发生,删除它不起作用,因为登录的 auth 端需要它。该指南和我的指南之间的唯一区别是我正在构建一个课堂应用程序,但使用它来指导我使用 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)
只是想让您知道,您正在学习的教程使用的是 firebase 网络版 8.x,您可能已经安装了 9.x 版,正如 [=13] 中指出的那样=].
如果情况并非如此,并且您使用的是正确的 SDK 版本,那么您可能需要说明如何导入依赖项,
此外,在文档中,我们可以找到一个 warning 来不断更新 firebase-functions sdk,正如您提到的那样,您在使用 install firebase
命令时会遇到错误。警告是:
In many cases, new features and bug fixes are available only with the latest version of the Firebase CLI and the 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:
npm install firebase-functions@latest firebase-admin@latest --save npm install -g firebase-tools
这些可能是导致此错误的主要原因。由于您没有提供任何代码,我还会检查是否通过 firebase 的更新对指南的某些部分进行了任何其他更改,您可能最终合并了不同版本的代码,就像他们所做的那样