- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经处理这个问题将近两个星期了。我尝试了很多解决方法,但似乎都没有奏效。我已经安装了angular-fire
和 firebase
到最新版本,试过ng add @angular/fire
, 配置自定义 webpack.config.ts
,尝试回滚到每个建议的先前版本。没有解决这个问题。
实际错误:
de-10@de10-LIFEBOOK-A555:~/Desktop$ node dist/server.js
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'firebase/app'
Require stack:
- /home/de-10/Desktop/dist/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/de-10/Desktop/dist/server.js:125276:18)
at __webpack_require__ (/home/de-10/Desktop/dist/server.js:20:30)
at Module.<anonymous> (/home/de-10/Desktop/dist/server.js:125199:70)
at __webpack_require__ (/home/de-10/Desktop/dist/server.js:20:30)
at Module.<anonymous> (/home/de-10/Desktop/dist/server.js:124984:78)
at __webpack_require__ (/home/de-10/Desktop/dist/server.js:20:30) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/de-10/Desktop/dist/server.js' ]
}
ERROR in ../node_modules/@angular/fire/auth/auth.d.ts:4:28 - error TS2307: Cannot find module 'firebase/app'.
4 import { User, auth } from 'firebase/app';
~~~~~~~~~~~~~~
../node_modules/@angular/fire/firebase.app.module.d.ts:2:74 - error TS2307: Cannot find module 'firebase/app'.
2 import { auth, database, messaging, storage, firestore, functions } from 'firebase/app';
~~~~~~~~~~~~~~
../node_modules/@angular/fire/firestore/collection-group/collection-group.d.ts:2:27 - error TS2307: Cannot find module 'firebase/app'.
~~~~~~~~~~~~~
.
.
.
app/services/notification.service.ts:29:38 - error TS2339: Property 'id' does not exist on type 'QueryDocumentSnapshot<unknown>'.
29 id: snap.payload.doc.id,
~~
app/services/notification.service.ts:68:35 - error TS2339: Property 'type' does not exist on type 'DocumentChange<unknown>'.
68 return snap.payload.type
~~~~
.
.
.
{
"name": "universal-ssr",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "npm run build:ssr",
"staging": "npm run build:ssr-staging && npm run serve:ssr",
"production": "npm run build:ssr && npm run serve:ssr",
"prod": "npm run build:ssr-production && npm run serve:ssr",
"build": "ng build --prod",
"test": "ng test",
"dev-start": "ng serve",
"ng serve": "ng serve --aot",
"lint": "ng lint",
"e2e": "ng e2e",
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"build:ssr-staging": "npm run build:client-and-server-bundles-staging && npm run webpack:server",
"build:ssr-production": "npm run build:client-and-server-bundles-production && npm run webpack:server",
"serve:ssr": "node dist/server.js",
"build:client-and-server-bundles": "ng build --prod --build-optimizer && ng run universal-ssr:server --bundleDependencies all",
"build:client-and-server-bundles-staging": "ng build --c=staging --build-optimizer=true --stats-json && ng run universal-ssr:server",
"build:client-and-server-bundles-production": "ng build --c=production --build-optimizer=true && ng run universal-ssr:server --bundleDependencies all",
"webpack:server": "webpack --config webpack.config.js --progress --colors",
"webpack:analyzer": "webpack-bundle-analyzer dist/browser/stats.json",
"compodoc": "npx compodoc -p src/tsconfig.app.json -o"
},
"private": true,
"dependencies": {
"@angular/animations": "^8.2.14",
"@angular/cdk": "^5.2.5",
"@angular/common": "^8.2.14",
"@angular/compiler": "^8.2.14",
"@angular/core": "^8.2.14",
"@angular/fire": "^5.4.2",
"@angular/forms": "^8.2.14",
"@angular/material": "^5.2.5",
"@angular/platform-browser": "^8.2.14",
"@angular/platform-browser-dynamic": "^8.2.14",
"@angular/platform-server": "^8.2.14",
"@angular/pwa": "^0.803.24",
"@angular/router": "^8.2.14",
"@angular/service-worker": "^8.2.14",
"@ng-bootstrap/ng-bootstrap": "^4.0.0",
"@nguniversal/express-engine": "^6.1.0",
"@nguniversal/module-map-ngfactory-loader": "^6.1.0",
"angular2-datetimepicker": "^1.1.1",
"bootstrap": "^4.4.1",
"city-timezones": "^1.2.0",
"core-js": "^2.6.11",
"cors": "^2.8.4",
"express": "^4.17.1",
"firebase": "^7.13.1",
"jquery": "^3.4.1",
"moment-timezone": "^0.5.27",
"ng-bootstrap": "^1.6.3",
"ng2-search-filter": "^0.5.1",
"ngx-clipboard": "12.2.1",
"ngx-google-places-autocomplete": "^2.0.4",
"ngx-pagination": "^3.3.1",
"ngx-spinner": "^2.0.0",
"ngx-toggle-switch": "^2.0.5",
"ngx-ui-switch": "^8.3.0",
"rxjs": "^6.5.4",
"rxjs-compat": "^6.0.0",
"save": "^2.4.0",
"ts-loader": "^4.0.0",
"tslib": "^1.10.0",
"uuid": "^3.4.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.23",
"@angular/cli": "^8.3.23",
"@angular/compiler-cli": "^8.2.14",
"@angular/http": "^7.2.16",
"@angular/language-service": "^8.2.14",
"@types/jasmine": "2.8.3",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^6.14.9",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "5.4.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~3.5.3",
"webpack-cli": "^3.1.0"
}
}
// Work around for https://github.com/angular/angular-cli/issues/7200
const path = require('path');
const webpack = require('webpack');
// change the regex to include the packages you want to exclude
const regex = /firebase\/(app|firestore)/;
module.exports = {
mode: 'production',
entry: {
// This is our Express server for Dynamic universal
server: './server.ts'
},
externals: {
'./dist/server/main': 'require("./server/main")'
},
target: 'node',
node: {
__dirname: false,
__filename: false,
},
resolve: { extensions: ['.ts', '.js'] },
target: 'node',
mode: 'none',
// this makes sure we include node_modules and other 3rd party libraries
externals: [/node_modules/, function (context, request, callback) {
// exclude firebase products from being bundled, so they will be loaded using require() at runtime.
if (regex.test(request)) {
return callback(null, 'commonjs ' + request);
}
callback();
}],
optimization: {
minimize: false
},
output: {
// Puts the output at the root of the dist folder
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
noParse: /polyfills-.*\.js/,
rules: [
{ test: /\.ts$/, loader: 'ts-loader' },
{
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
// Removing this will cause deprecation warnings to appear.
test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
parser: { system: true },
},
]
},
plugins: [
new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'), // location of your src
{} // a map of your routes
),
new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
};
import 'zone.js/dist/zone-node';
import * as express from 'express';
/* const express = require('express');
const join = require('path'); */
const compression = require('compression')
import { join } from 'path';
// Express server
const app = express();
// gzip
app.use(compression())
const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(__dirname, 'browser');/* 'dist/browser' */
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP, ngExpressEngine, provideModuleMap } = require('./dist/server/main');
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [
provideModuleMap(LAZY_MODULE_MAP)
]
}));
app.set('view engine', 'html');
app.set('views', DIST_FOLDER);
// Serve static files from /browser
app.get('*.*', express.static(DIST_FOLDER, {
maxAge: '1y'
}));
// All regular routes use the Universal engine
app.get('*', (req, res) => {
res.render('index', { req });
});
// Start up the Node server
app.listen(PORT, () => {
console.log(`Node Express server listening on http://localhost:${PORT}`);
});
最佳答案
您收到此错误是因为您使用 this => 排除了 Firebase 依赖项
const regex = /firebase\/(app|firestore)/;
module.exports = {
// this makes sure we include node_modules and other 3rd party libraries
externals: [/node_modules/, function (context, request, callback) {
// exclude firebase products from being bundled, so they will be loaded using require() at runtime.
if (regex.test(request)) {
return callback(null, 'commonjs ' + request);
}
callback();
}],
};
删除这个
if (regex.test(request)) {
return callback(null, 'commonjs ' + request);
}
你的应用程序会很好。
关于firebase - 部署 Angular Universal 应用程序时找不到模块 'firebase/app',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61367903/
请帮助我了解如何在 Angular Universal 中使用服务器渲染。 我做了什么。我访问了 Angular Universal 官方网站。设置 Node.js。下载推荐项目 Angular 2
我正在研究使用 explicit universes 的可能性用于在 Coq 中构建固定的 Universe 层次结构。在构建它时使用常量 (2, 3, 4) 的尝试失败了:最后,所有组合仍然类型检查
我查看了 Universal Analytics,但没有找到问题的正确答案。 如何将这一行从旧的 Analytics 更新到新的 Universal Analytics? _gaq.push(["_s
我在 IIS 中部署 angular 通用应用程序时遇到问题。在 angular 通用中,创建了两个 dist 文件夹,一个是客户端的 dist,另一个是 dist-server,当我尝试托管时,我提
我使用@ng-toolkit/universal 作为我的服务器端渲染方法。一切正常,没有我的图像。我正在动态地获取它们。因此,当用户没有头像时,会显示一个占位符图像。因此我正在使用这个函数: ver
-编译应用程序后,我多次收到此错误 enter image description here 文本错误: 错误错误 at XMLHttpRequest.send (C:\Users\seva-
我正在Win10中使用VS2015开发通用应用程序。模拟器和android模拟器运行正常。 但是,当我启动Windows Phone Mobile模拟器时,该模拟器运行并显示“操作系统正在启动”,然后
我正在实现一个路由保护(CanActivate 接口(interface)),我需要在某些条件下重定向到未找到的页面。这可以通过以下语句来实现: if (isNode){ let res : Resp
我偶然发现了一个奇怪的情况,其中有 reflect.runtime.universe._进口原因reflect.runtime.universe.RuntimeClass推断它似乎在哪里Nothing
每当我在我的应用程序中加载图像时,我的 logcat 都会给我这条消息。 04-09 19:09:59.241: W/ImageLoader(276): Try to initialize Image
我正在尝试添加包但出现错误 meteor add universe:carousel => Errors while adding packages: 选择软件包版本时: error: Confli
所以我一直在尝试将我的应用程序转换为 angular universal,并且在大多数情况下都很好。但我之前读过一些“陷阱”:https://github.com/onespeed-articles/
我有一个指令,使文本输入到谷歌的地方自动完成输入,看起来像: import { Directive, AfterViewInit , Output, EventEmitter, NgZone, Ele
大约一年前,我们升级到了通用Analytics(分析),由于升级我们的站点搜索并没有在我们的Analytics(分析)帐户中显示关键字,甚至没有跟踪其使用次数。 作为营销人员,这是一个问题,因为我想知
我正准备使用 Angular Universal 为我的 Angular 7 应用程序设置 SSR。我遵循了官方文档( https://angular.io/guide/universal )。我到了
在应用程序关闭(暂停)后,我正在将一个不大于 10KB 的数据文件写入 RoamingFolder。该应用程序在开发桌面和 Surface 2 上运行,两者都登录到同一个 Microsoft 帐户。但
This question already has answers here: Page Navigation using MVVM in Store App (5个答案) 6年前关闭。 使用MVVM
我尝试安装iOS-Universal-Framework 。尝试运行instalation shell screept从这个存储库并始终获取消息: iOS Real Static Framework
这就是我目前初始化 chromedriver 的方式 System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe"); 但是
您好,我在尝试运行 perl 脚本时遇到以下错误: pc:~/Phd/lenovo/programs/vep/scripts/variant_effect_predictor$ perl varian
我是一名优秀的程序员,十分优秀!