我正在构建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
}
如何解决此错误?
答案 0 :(得分:0)
问题似乎与ng-toolkit / universal依赖性有关。依赖关系是一个cli,可帮助您设置样板项目,并且从其github页面(https://github.com/maciejtreder/ng-toolkit#readme)中,我看到该依赖关系应全局安装,而不应随应用程序一起提供。将依赖关系移至package.json中的devDependency或仅将其全局安装并从package.json中删除
答案 1 :(得分:0)
您可以使用Rendertron
进行服务器端渲染,它不需要Angular Universal或任何奇怪的技巧。只需专注于开发Angular应用程序即可。
https://angularfirebase.com/lessons/seo-angular-part-1-rendertron-meta-tags/