Angular 通用不使用新代码重建

Angular universal not rebuilding with new code

我最初在我的 angular cli 项目中安装了 jQuery(我知道这是个坏主意),但是我现在删除了它,因为显然它在转换为 angular 通用.

我现在已经从项目中卸载 jQuery 并检查没有其他插件依赖它但是当我重建项目时 运行 它仍然出现 jQuery定义的错误,它显示了我的应用程序模式组件的旧代码,该组件以前使用 jQuery.

它出现的错误是,我不确定为什么会这样?

我的应用程序模态组件的代码是

^ 但它在 server.js

中并没有那样显示

我的 package.json 包含以下内容

{ "name": "offigo-v2", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server", "serve:ssr": "node dist/server.js", "build:client-and-server-bundles": "ng build --prod && ng build --prod --project=offigo-v2", "webpack:server": "webpack --config webpack.server.config.js --progress --colors", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^6.1.10", "@angular/common": "^6.1.10", "@angular/compiler": "^6.1.10", "@angular/core": "^6.1.10", "@angular/forms": "^6.1.10", "@angular/http": "^6.1.10", "@angular/platform-browser": "^6.1.10", "@angular/platform-browser-dynamic": "^6.1.10", "@angular/platform-server": "^7.0.4", "@angular/router": "^6.1.10", "@mdi/font": "^2.8.94", "@nguniversal/module-map-ngfactory-loader": "^7.0.2", "@tinymce/tinymce-angular": "^2.3.1", "@types/leaflet": "^1.2.14", "angular2-tinymce": "^3.3.0", "bootstrap": "^4.1.3", "core-js": "^2.5.4", "croppie": "^2.6.2", "leaflet": "^1.3.4", "leaflet-gesture-handling": "^1.1.8", "material-design-icons": "^3.0.1", "moment": "^2.22.2", "ngx-lazy-load-images": "^1.3.1", "popper.js": "^1.14.5", "rxjs": "^6.3.3", "siema": "^1.5.1", "tinymce": "^4.8.5", "ts-loader": "^5.3.0", "typeface-cabin": "0.0.54", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.6.8", "@angular/cli": "^6.2.7", "@angular/compiler-cli": "^6.1.10", "@angular/language-service": "^6.1.10", "@types/jasmine": "^2.8.12", "@types/jasminewd2": "^2.0.6", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^2.0.4", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "^2.9.2", "webpack-cli": "^3.1.2" } }

和 angular.json

{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "offigo-v2": { "root": "", "sourceRoot": "src", "projectType": "application", "prefix": "app", "schematics": {}, "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/offigo-v2", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", "preserveSymlinks": true, "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css", "node_modules/material-design-icons/iconfont/material-icons.css", "node_modules/leaflet/dist/leaflet.css", "node_modules/@mdi/font/css/materialdesignicons.min.css", "node_modules/typeface-cabin/index.css", "node_modules/croppie/croppie.css", "node_modules/leaflet-gesture-handling/dist/leaflet-gesture-handling.min.css", "node_modules/tinymce/tinymce.min.js", "src/styles.css" ], "scripts": [ "node_modules/popper.js/dist/umd/popper.min.js", "node_modules/bootstrap/dist/js/bootstrap.min.js", "node_modules/croppie/croppie.min.js" ] }, "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 } } }, "server": { "builder": "@angular-devkit/build-angular:server", "options": { "outputPath": "dist/offigo-server", "main": "src/main.server.ts", "tsConfig": "src/tsconfig.server.json" } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "offigo-v2: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" ] } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "offigo-v2:build" }, "configurations": { "production": { "browserTarget": "offigo-v2:build:production" } } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ], "exclude": [ "**/node_modules/**" ] } } } }, "offigo-v2-e2e": { "root": "e2e/", "projectType": "application", "architect": { "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", "devServerTarget": "offigo-v2:serve" }, "configurations": { "production": { "devServerTarget": "offigo-v2:serve:production" } } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": "e2e/tsconfig.e2e.json", "exclude": [ "**/node_modules/**" ] } } } } }, "defaultProject": "offigo-v2" }

问题出在您的 popper.jsbootstrap.js 上,因为两者都取决于 jquery。

请试试这个 angular 原生 bootstrap 库 Bootstrap

由于某些原因 npm run build:server 没有更新服务器版本中的 main.js,我 运行 ng run offigo-v2:server 更新了服务器版本以便 server.js 不会包含旧代码。