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

标签 firebase google-cloud-functions firebase-tools

我一直致力于 Firebase 函数项目,在本地运行该服务进行测试。

一切都工作正常,但后来我将源文件夹移动到一个新位置(到源代码管理中),现在它无法运行,因为某处的某些东西记住了项目的旧位置.

那么 Firebase 到底在哪里“记住”项目/源的原始位置?

我该如何解决这个问题?


更多信息:

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

下面是我运行“firebaseserve--onlyfunctions”并点击服务 URL 时的输出。

忽略带有“无法模拟...”和“无 HTTPS...”的行 - 这是正常的。 下一个“error:”行,其余部分在点击 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 开发环境中研究同样的问题时看到了你的帖子。我从 NFS 共享复制了一些代码到我的主目录,但我终其一生都无法让它在函数模拟器中运行 - 问题之一是代码仍在 NFS 安装路径上运行,而不是在 NFS 安装路径上运行。我运行 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

不幸的是,我没有 100% 确定的“之前和之后”,请告诉我这是否可以解决您的问题。

关于firebase - "firebase serve --only functions"移动项目文件夹后中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45910552/

相关文章:

node.js - Firebase 功能部署失败

javascript - Firebase 云消息传递 : event is not defined

node.js - Firestore 本地 http 与真实数据库 : The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error

java - 组织 firebase 数据

android - Firebase Cloud Messaging 将服务器 key 替换为用于发送通知/消息的 token

html - Firebase Cookie 限制

Firebase CLI 未进行身份验证,因为 Google 帐户未保留授权

function - firebase deploy --only 函数覆盖现有函数

java - 如何从 Firebase 数据库检索图像并将其显示在 RecyclerView 中?

android - 获取当前用户详细信息,即登录 firebase 的用户