Javascript Angular 7 npm运行服务:安装Angular universal后使用时ssr失败
`npm运行服务:ssr 经销商网站-app@0.0.0服务:ssr C:\Users\ehsaan\Desktop\checkNow\DealerSites.App node local.js 收听: 错误类型错误:$。ajax不是函数 在ConfigService.module.exports../src/app/_configurationservice/config.service.ts.ConfigService.run(C:\Users\ehsaan\Desktop\checkNow\DealerSites.app\dist\server.js:132942:11) ` 这是我的package.jsonJavascript Angular 7 npm运行服务:安装Angular universal后使用时ssr失败,javascript,jquery,angular,webpack,angular-universal,Javascript,Jquery,Angular,Webpack,Angular Universal,`npm运行服务:ssr 经销商网站-app@0.0.0服务:ssr C:\Users\ehsaan\Desktop\checkNow\DealerSites.App node local.js 收听: 错误类型错误:$。ajax不是函数 在ConfigService.module.exports../src/app/_configurationservice/config.service.ts.ConfigService.run(C:\Users\ehsaan\Desktop\checkNow
{
"name": "dealer-sites-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"compile:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:ssr": "node local.js",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
"build:client-and-server-bundles": "ng build --prod && ng run DealerSitesApp:server:production",
"server": "node local.js",
"build:prod": "npm run build:ssr",
"serve:prerender": "node static.js",
"build:prerender": "npm run build:prod && node dist/prerender.js"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.15",
"@angular/cdk": "^7.3.7",
"@angular/common": "^7.2.15",
"@angular/compiler": "^7.2.15",
"@angular/core": "^7.2.15",
"@angular/forms": "^7.2.15",
"@angular/http": "~7.2.0",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "^7.2.15",
"@angular/platform-browser-dynamic": "^7.2.15",
"@angular/platform-server": "~7.2.0",
"@angular/router": "^7.2.15",
"@auth0/angular-jwt": "^2.1.2",
"@ng-toolkit/universal": "^7.1.2",
"@nguniversal/common": "0.0.0",
"@nguniversal/express-engine": "0.0.0",
"@nguniversal/module-map-ngfactory-loader": "0.0.0",
"alertifyjs": "^1.11.4",
"angular-colorbox": "^1.1.5",
"angular-font-awesome": "^3.1.2",
"angular2-jwt": "^0.2.3",
"angular2-text-mask": "^9.0.0",
"bootstrap": "^3.4.0",
"core-js": "^2.6.9",
"domino": "^2.1.3",
"express": "^4.17.1",
"font-awesome": "^4.7.0",
"jquery": "^3.4.1",
"jquery-colorbox": "^1.6.4",
"ngx-bootstrap": "^3.3.0",
"ngx-currency": "^2.0.0",
"ngx-mask": "^7.9.10",
"popper": "^1.0.1",
"rxjs": "~6.3.3",
"rxjs-compat": "^6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.9",
"@angular/cli": "^7.3.9",
"@angular/compiler-cli": "^7.2.15",
"@angular/language-service": "^7.2.15",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^2.0.54",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-loader": "^5.2.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2",
"webpack-cli": "^3.3.9"
}
}
`
**Here is my angular.json**
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"DealerSitesApp": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/DealerSitesApp",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.js",
"node_modules/alertifyjs/build/alertify.min.js",
"node_modules/jquery-colorbox/jquery.colorbox-min.js"
],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "DealerSitesApp:build"
},
"configurations": {
"production": {
"browserTarget": "DealerSitesApp:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "DealerSitesApp:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"DealerSitesApp-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "DealerSitesApp:serve"
},
"configurations": {
"production": {
"devServerTarget": "DealerSitesApp:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "DealerSitesApp"
}
**This is my app.module**
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { APP_INITIALIZER, Injector, LOCALE_ID } from '@angular/core';
import { JwtModule } from '@auth0/angular-jwt';
import * as $ from 'jquery';
import { PaginationModule } from 'ngx-bootstrap';
import { BsDatepickerModule } from 'ngx-bootstrap';
import { NgxMaskModule, IConfig } from 'ngx-mask';
import { NgxCurrencyModule } from 'ngx-currency';
import { TextMaskModule } from 'angular2-text-mask';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
import { NavComponent } from './nav/nav.component';
import { HomeComponent } from './home/home.component';
import { InventoryComponent } from './vehicles/vehicle-inventory/inventory.component';
import { FinancingComponent, SafePipe } from './financing/financing.component';
import { LocationComponent } from './location/location.component';
import { ContactComponent } from './contact/contact.component';
import { SidebarComponent } from './sidebar/sidebar.component';
import { VehicleDetailComponent } from './vehicles/vehicle-detail/vehicle-detail.component';
import { EmailDetailsComponent } from './vehicles/email-details/email-details.component';
import { RequestInfoComponent } from './vehicles/request-info/request-info.component';
import { ColorboxComponent } from './vehicles/colorbox/colorbox.component';
import { appRoutes } from './routes';
import { AppConstants } from './_models/constants';
import { TokenInterceptor } from './_services/token.interceptor';
import { AppInitializer } from './_configurationservice/app-initializer';
import { ConfigService } from './_configurationservice/config.service';
import { VehicleService } from './_services/vehicle.service';
import { StartupService } from './_services/startup.service';
import { SiteService } from './_services/site.service';
import { AuthService } from './_services/auth.service';
import { VehicleDetailResolver } from './_resolver/vehicle-detail.resolver';
import { InventoryListResolver } from './_resolver/inventory-list.resolver';
export function initialize_app(appInitializer: AppInitializer) {
return () => appInitializer.run();
}
export function tokenGetter() {
return localStorage.getItem('token');
}
// tslint:disable-next-line: ban-types
export function startupServiceFactory(startupservice: StartupService): Function {
return () => startupservice.load();
}
export let options: Partial<IConfig> | (() => Partial<IConfig>);
// export let customCurrencyMaskConfig = {
// align: 'left',
// allowNegative: false,
// allowZero: true,
// decimal: ',',
// precision: 3,
// prefix: '$',
// suffix: '',
// thousands: '.',
// nullable: true
// };
export let customCurrencyMaskConfig = {
align: 'left',
allowNegative: false,
allowZero: true,
decimal: ',',
precision: 0,
prefix: '$',
suffix: '',
thousands: ',',
nullable: true
};
@NgModule({
declarations: [
AppComponent,
SafePipe,
HomeComponent,
ContactComponent,
InventoryComponent,
FinancingComponent,
LocationComponent,
VehicleDetailComponent,
SidebarComponent,
EmailDetailsComponent,
HeaderComponent,
FooterComponent,
NavComponent,
ColorboxComponent,
RequestInfoComponent,
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
BrowserAnimationsModule,
TextMaskModule,
NgxCurrencyModule.forRoot(customCurrencyMaskConfig),
RouterModule.forRoot(appRoutes, { useHash: true }),
BsDatepickerModule.forRoot(),
PaginationModule.forRoot(),
// JwtModule.forRoot({
// config:{
// tokenGetter:tokenGetter,
// whitelistedDomains: ['localhost:44346'],
// blacklistedRoutes: ['localhost:44346/api/auth']
// }
// })
],
providers: [
InventoryListResolver,
VehicleDetailResolver,
SiteService,
AuthService,
VehicleService,
AppInitializer,
AppConstants,
{
provide: ConfigService,
useClass: ConfigService,
deps: [AppConstants]
},
{
provide: APP_INITIALIZER,
useFactory: initialize_app,
deps: [AppInitializer],
multi: true
},
{
provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptor,
multi: true
}
],
bootstrap: [AppComponent]
})
export class AppModule { }
{
“名称”:“经销商网站应用程序”,
“版本”:“0.0.0”,
“脚本”:{
“ng”:“ng”,
“开始”:“ng发球”,
“构建”:“ng构建”,
“测试”:“ng测试”,
“皮棉”:“ng皮棉”,
“e2e”:“ng e2e”,
“编译:服务器”:“webpack--config webpack.server.config.js--progress--colors”,
“serve:ssr”:“node local.js”,
“构建:ssr”:“npm运行构建:客户端和服务器捆绑包和&npm运行编译:服务器”,
“build:客户端和服务器捆绑包”:“ng build--prod&&ng run DealerSitesApp:服务器:生产”,
“服务器”:“node local.js”,
“构建:产品”:“npm运行构建:ssr”,
“服务:预渲染”:“node static.js”,
“build:prerender”:“npm运行build:prod&&node dist/prerender.js”
},
“私人”:没错,
“依赖项”:{
“@angular/animations”:“^7.2.15”,
“@angular/cdk”:“^7.3.7”,
“@angular/common”:“^7.2.15”,
“@angular/compiler”:“^7.2.15”,
“@angular/core”:“^7.2.15”,
“@angular/forms”:“^7.2.15”,
“@angular/http”:“~7.2.0”,
“@angular/material”:“^7.3.7”,
“@角度/平台浏览器”:“^7.2.15”,
“@angular/platform browser dynamic”:“^7.2.15”,
“@angular/platform服务器”:“~7.2.0”,
“@angular/router”:“^7.2.15”,
“@auth0/angular jwt”:“^2.1.2”,
“@ng toolkit/universal”:“^7.1.2”,
“@nguniversal/common”:“0.0.0”,
“@nguniversal/express引擎”:“0.0.0”,
“@nguniversal/模块映射ngfactory loader”:“0.0.0”,
“alertifyjs”:“^1.11.4”,
“角度色盒”:“^1.1.5”,
“棱角字体很棒”:“^3.1.2”,
“angular2 jwt”:“^0.2.3”,
“angular2文本掩码”:“^9.0.0”,
“引导”:“^3.4.0”,
“核心js”:“^2.6.9”,
“domino”:“^2.1.3”,
“快车”:“^4.17.1”,
“字体真棒”:“^4.7.0”,
“jquery”:“^3.4.1”,
“jquery颜色框”:“^1.6.4”,
“ngx引导”:“^3.3.0”,
“ngx货币”:“^2.0.0”,
“ngx掩码”:“^7.9.10”,
“波普尔”:“^1.0.1”,
“rxjs”:“~6.3.3”,
“rxjs compat”:“^6.5.3”,
“tslib”:“^1.10.0”,
“zone.js”:“~0.8.26”
},
“依赖性”:{
“@angular devkit/build angular”:“^0.13.9”,
“@angular/cli”:“^7.3.9”,
“@angular/compiler cli”:“^7.2.15”,
“@angular/language service”:“^7.2.15”,
“@types/jasmine”:“~2.8.8”,
“@types/jasminewd2”:“~2.0.3”,
“@types/jquery”:“^2.0.54”,
“@types/node”:“~8.9.4”,
“codelyzer”:“~4.5.0”,
“茉莉花芯”:“~2.99.1”,
“jasmine spec reporter”:“~4.2.1”,
“因果报应”:“~4.0.0”,
“卡玛铬发射器”:“~2.2.0”,
“因果报应报道伊斯坦布尔记者”:“^2.0.6”,
“因果报应茉莉”:“~1.1.2”,
“karma jasmine html reporter”:“^0.2.2”,
“量角器”:“~5.4.0”,
“ts加载器”:“^5.2.0”,
“ts节点”:“~7.0.0”,
“tslint”:“~5.11.0”,
“类型脚本”:“~3.2.2”,
“网页包cli”:“^3.3.9”
}
}
`
**这是我的angular.json**
{
“$schema”:“/node_modules/@angular/cli/lib/config/schema.json”,
“版本”:1,
“newProjectRoot”:“项目”,
“项目”:{
“DealerSitesApp”:{
“根”:“,
“sourceRoot”:“src”,
“项目类型”:“应用程序”,
“前缀”:“应用程序”,
“示意图”:{},
“建筑师”:{
“构建”:{
“生成器”:“@angular devkit/build angular:browser”,
“选择”:{
“outputPath”:“dist/DealerSitesApp”,
“索引”:“src/index.html”,
“main”:“src/main.ts”,
“polyfills”:“src/polyfills.ts”,
“tsConfig”:“src/tsConfig.app.json”,
“资产”:[
“src/favicon.ico”,
“src/资产”
],
“风格”:[
“node_modules/bootstrap/dist/css/bootstrap.min.css”,
“src/styles.css”
],
“脚本”:[
“node_modules/jquery/dist/jquery.min.js”,
“node_modules/bootstrap/dist/js/bootstrap.js”,
“node_modules/alertifyjs/build/alertify.min.js”,
“node_modules/jquery colorbox/jquery.colorbox-min.js”
],
“es5BrowserSupport”:正确
},
“配置”:{
“生产”:{
“文件替换”:[{
“替换”:“src/environments/environment.ts”,
“with”:“src/environments/environment.prod.ts”
}],
“优化”:没错,
“输出授权”:“全部”,
“sourceMap”:false,
是的,
“namedChunks”:假,
“aot”:是的,
是的,
“vendorChunk”:假,
“buildOptimizer”:正确,
“预算”:[{
“类型”:“首字母”,
“最大警告”:“2mb”,
“最大错误”:“5mb”
}]
}
}
},
“发球”:{
“生成器”:“@angular devkit/build angular:dev server”,