代码之家  ›  专栏  ›  技术社区  ›  Hitesh Garg

@ng toolkit/universal的firebase函数部署失败

  •  0
  • Hitesh Garg  · 技术社区  · 6 年前

    我正在构建angular 7应用程序,并使用angular universal进行服务器端渲染,一切在本地运行良好,但是当我尝试在firebase上部署应用程序时,firebase函数日志显示以下错误-

    {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"Build failed: exit status 254\nnpm ERR! addLocal Could not install /workspace/node_modules/@ng-toolkit/universal/@ng-toolkit/_utils@1.1.50\nnpm WARN deprecated bugsnag@2.4.3: All projects should upgrade to our universal JS notifier: \"@bugsnag/js\". See https://github.com/bugsnag/bugsnag-js/blob/master/UPGRADING.md for more details.\nnpm ERR! Linux 4.15.0-1026-gcp\nnpm ERR! argv \"/nodejs/bin/node\" \"/nodejs/bin/npm\" \"--global-style\" \"--production\" \"--fetch-retries=5\" \"--fetch-retry-factor=2\" \"--fetch-retry-mintimeout=1000\" \"install\" \"/workspace\"\nnpm ERR! node v6.14.0\nnpm ERR! npm  v3.10.10\nnpm ERR! path /workspace/node_modules/@ng-toolkit/universal/@ng-toolkit/_utils@1.1.50\nnpm ERR! code ENOENT\nnpm ERR! errno -2\nnpm ERR! syscall open\n\nnpm ERR! enoent ENOENT: no such file or directory, open '/workspace/node_modules/@ng-toolkit/universal/@ng-toolkit/_utils@1.1.50'\nnpm ERR! enoent ENOENT: no such file or directory, open '/workspace/node_modules/@ng-toolkit/universal/@ng-toolkit/_utils@1.1.50'\nnpm ERR! enoent This is most likely not a problem with npm itself\nnpm ERR! enoent and is related to npm not being able to find a file.\nnpm ERR! enoent \n\nnpm ERR! Please include the following file with any support request:\nnpm ERR!     /workspace/npm-debug.log\n"},"authenticationInfo":.....
    

    functions/package.json中的设置

    {
      "name": "functions",
      "description": "Cloud Functions for Firebase",
      "scripts": {
        "serve": "firebase serve --only functions",
        "shell": "firebase functions:shell",
        "start": "npm run shell",
        "deploy": "firebase deploy --only functions",
        "logs": "firebase functions:log"
      },
      "dependencies": {
        "@angular/animations": "~7.0.0",
        "@angular/common": "~7.0.0",
        "@angular/compiler": "~7.0.0",
        "@angular/core": "~7.0.0",
        "@angular/fire": "^5.1.1",
        "@angular/forms": "~7.0.0",
        "@angular/http": "~7.0.0",
        "@angular/platform-browser": "~7.0.0",
        "@angular/platform-browser-dynamic": "~7.0.0",
        "@angular/platform-server": "~7.0.0",
        "@angular/router": "~7.0.0",
        "@ng-toolkit/universal": "^1.1.50",
        "@nguniversal/express-engine": "~7.0.0",
        "@nguniversal/module-map-ngfactory-loader": "~7.0.0",
        "bootstrap": "^4.1.3",
        "bootswatch": "^4.1.3",
        "core-js": "^2.5.4",
        "cors": "~2.8.4",
        "firebase": "^5.7.2",
        "font-awesome": "^4.7.0",
        "jquery": "^3.3.1",
        "rxjs": "~6.3.3",
        "ts-loader": "4.2.0",
        "webpack-cli": "^3.1.2",
        "zone.js": "~0.8.26",
        "@nguniversal/common": "~7.0.0",
        "express": "~4.16.3",
        "firebase-admin": "~6.0.0",
        "firebase-functions": "^2.1.0"
      },
      "private": true
    }
    

    如何修复这个错误?

    2 回复  |  直到 6 年前
        1
  •  0
  •   lazreg87    6 年前

    这些问题似乎与ng工具包/通用依赖性有关。依赖项是一个cli,它帮助您设置样板项目并从它们的github页面( https://github.com/maciejtreder/ng-toolkit#readme )我看到依赖项应该是全局安装的,而不是应用程序本身附带的。将依赖项移动到package.json中的devdependency,或者只需全局安装并从package.json中删除它。

        2
  •  0
  •   Chunbin Li    6 年前

    你可以使用 Rendertron 对于服务器端渲染,它不需要角通用或任何奇怪的黑客。只需专注于开发角度应用程序。

    https://angularfirebase.com/lessons/seo-angular-part-1-rendertron-meta-tags/