4

我正在尝试使用 Cloud FunctionsNextJS提供动态内容。

当我运行时,一切都按预期在本地工作firebase serve

但是,当我运行firebase deploy并尝试运行我的函数时,我在 firebase 函数日志中收到以下错误。

在此处输入图像描述

Error: Cannot find module 'babel-runtime/core-js/object/get-prototype-of'
    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 Object.<anonymous> (/user_code/next/dist/pages/_document.js:7:23)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

我没有直接使用 babel(我使用的是 typescript),所以我的一个模块必须将它用作依赖项。

我猜我已经在本地机器上全局安装了一些东西,但它不存在于我的云功能中,但我该如何调试这将是什么?我尝试添加babel-runtime到我的 package.json

node -v v6.11.5

package.json

{
  "name": "functions",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "lint": "./node_modules/.bin/tslint -p tslint.json",
    "build-js": "./node_modules/.bin/tslint -p tslint.json && ./node_modules/.bin/tsc && cp package.json ../../build/functions/package.json"
  },
  "main": "index.js",
  "dependencies": {
    "async": "^2.6.0",
    "@babel/runtime": "^7.0.0-beta.39",
    "express": "^4.15.4",
    "firebase-admin": "~5.8.1",
    "firebase-functions": "^0.8.1",
    "googleapis": "^23.0.0",
    "next": "^4.2.1",
    "range-inclusive": "^1.0.2",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "request": "^2.83.0",
    "request-promise": "^4.2.2",
    "typescript": "^2.7.1"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.0.0-beta.39",
    "babel-runtime": "^6.26.0",
    "tslint": "^5.8.0",
    "typescript": "^2.7.1"
  },
  "private": true
}
4

0 回答 0