Nx + Firebase:不能 运行 模拟器

Nx + Firebase: Can't run emulators

我正在尝试 运行 Nx 工作区中的 Firebase 模拟器。

我在项目中添加了 firebase:

npm install firebase @angular/fire --save

nx g @angular/fire:ng-add // sets up package in project (this didn't work)
ng add @angular/fire // sets up package in project (this worked)

我在本地文件夹中初始化了 firebase:

firebase init

我尝试 运行 模拟器:

firebase emulators:start

我得到以下控制台输出:

PS C:\repos\todoapp> firebase emulators:start i emulators: Starting emulators: auth, functions, firestore, hosting, storage ! functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, pubsub

  • functions: Using node@14 from host. i firestore: Firestore Emulator logging to firestore-debug.log i hosting: Serving hosting files from: dist/todoapp
  • hosting: Local server: http://localhost:5000 i ui: Emulator UI logging to ui-debug.log i functions: Watching "C:\repos\todoapp\functions" for Cloud Functions... ! Error: Cannot find module 'C:\repos\todoapp\functions\lib\index.js'. Please verify that the package.json has a valid "main" entry at tryPackage (internal/modules/cjs/loader.js:321:19) at Function.Module._findPath (internal/modules/cjs/loader.js:534:18) 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 initializeRuntime (C:\Users\patri\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:687:29) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async handleMessage (C:\Users\patri\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js:729:20) ! We were unable to load your functions code. (see above)
    • It appears your code is written in Typescript, which must be compiled before emulation.
    • You may be able to run "npm run build" in your functions directory to resolve this.

Nx 不能与 Firebase 无缝协作吗?

我是否必须进行一些额外的设置才能无缝地运行,就像在标准 Angular 环境中一样?

我运行也喜欢这个。在您的 functions 文件夹中,您需要执行 npm run build 以生成它正在寻找的文件。