"firebase serve --only functions" 移动项目文件夹后中断

"firebase serve --only functions" breaks after moving project folder

我一直在做一个 Firebase 函数项目,运行在本地测试服务。

一切正常,但后来我将源文件夹移动到一个新位置(进入源代码管理),现在它不会 运行,因为某处某处记得项目的旧位置.

那么 Firebase 'remembering' 到底在哪里 project/source?

我该如何解决?


更多信息:

平台: Windows 7
节点:v6.11.1(建议:https://cloud.google.com/functions/docs/writing

下面是我 运行 'firebase serve --only functions' 并点击服务 URL 时的输出。

忽略带有“模拟失败...”和“无 HTTPS...”的行 - 这是正常的。 下一个“错误:”行,其余部分在 URL 被命中时发出。

重点是:

a) The folder my project is in is shown on the first line (In standard Windows CMD prompt fashion)

b) The "Cannot find module" error is looking in A COMPLETELY DIFFERENT FOLDER. In fact, it is looking where the project USED to be.

D:\_DEV\svn\FredSays\onGoogleAssistant\functions>firebase serve --only functions

=== Serving from 'D:\_DEV\svn\FredSays\onGoogleAssistant'...

i  functions: Preparing to emulate HTTPS functions. Support for other event types coming soon.
!  functions: Failed to emulate FredSays
i  functions: No HTTPS functions emulated. Support for other function types are coming soon.
error: module.js:471
    throw err;
    ^

Error: Cannot find module 'D:\_DEV\FredSays\actionssdk-say-number-nodejs-master\functions'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at process.on.e (D:\_TOOLS\nvm\v6.11.1\node_modules\firebase-tools\node_modules\@google-cloud\functions-emulator\src\supervisor\worker.js:64:28)
    at emitTwo (events.js:106:13)
    at process.emit (events.js:191:7)
    at process.nextTick (internal/child_process.js:758:12)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
error: Function worker crashed with exit code: 1

我在列出旧位置的项目树中找不到任何内容。 我已经尝试了以下所有方法:

npm cache clean
firebase init functions
firebase logout & firebase login
DEL /S /Q node_modules & npm install
npm uninstall -g firebase-tools & npm install -g firebase-tools

以上都没有帮助。

请帮忙。我的项目现在已经死了。

我在 Ubuntu 开发环境中研究同样的问题时遇到了你的 post。我从 NFS 共享中复制了一些代码到我的主目录,但我终其一生都无法在函数模拟器中将它复制到 运行 - 其中一个问题是代码仍然是 运行在 NFS 安装路径上,而不是我 运行ning VS Code 所在的本地路径。

移动代码后需要重新定位代码的命令是

$firebase use
Active Project: fbgo-9f73a

Project aliases for /home/user/firebase/chappy:

* default (site-ID)

Run firebase use --add to define a new project alias.

然后启动模拟器

$ firebase serve --only functions,hosting

=== Serving from '/home/user/firebase/chappy'...

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000

✔  functions: app: http://localhost:5003/site-ID/us-central1/app

不幸的是,我没有 'before and after' 可以 100% 确定,如果这能为您解决问题,请告诉我。