Angular SSR Firebase 托管

时间:2021-06-07 05:40:45

标签: angular firebase server-side-rendering

我已经按照教程进行操作,并且能够设置 Angular SSR。一切正常。现在我试图将它托管到 firebase,但我似乎无法让它工作。

运行 firebase server - Error: Cannot find module D:\Git\Test-SSR\test-ssr-app\functions\dist\server 时出现此错误

这是我的 index.json

import * as functions from "firebase-functions";

const universal = require(`${process.cwd()}\\dist\\server`).app();

export const ssr = functions.https.onRequest(universal);

这是我的 cp-angular.js

const fs = require('fs-extra');

(async() => {

    const src = '../dist';
    const copy = './dist';

    await fs.remove(copy);
    await fs.copy(src, copy);


})();

这是我的 package.json

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "node cp-angular && tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "12"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^9.2.0",
    "firebase-functions": "^3.11.0",
    "fs-extra": "^10.0.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^3.9.1",
    "@typescript-eslint/parser": "^3.8.0",
    "eslint": "^7.6.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.22.0",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^3.8.0"
  },
  "private": true
}

我可以在驱动器上看到文件夹 D:\Git\Test-SSR\test-ssr-app\functions\dist\server 存在,并且有一些 js 文件,包括 main.js。

我在这里做错了什么?

感谢任何帮助

0 个答案:

没有答案
相关问题