SyntaxError:angular4 + Universal之后出现意外的令牌

问题描述 投票:0回答:1

我被困在使用通用的SEO友好角色4。

我已按照此处提供的步骤操作。 https://github.com/neoighodaro/Angular-SEO-friendly-example/blob/master/tutorial.md与我现有的申请。

如果我创建单独的应用程序,我将获得完美的输出。

但是,当我试图整合现有的ang4时,它会抛出错误。

我已经逐一解决了所有问题。但

"ang\angular\node_modules\ngx-bootstrap\modal\index.js:1
 (function (exports, require, module, __filename, __dirname) { export { 
 BsModalRef } from './bs-modal-ref.service';
   ^^^^^^SyntaxError: Unexpected token export

这是我的package.json

{
        "name": "angular2-cli",
        "version": "0.0.0",
        "license": "MIT",
        "scripts": {
          "prestart": "ng build -- eve=prod --aot=false && ngc",
          "start": "ts-node src/server.ts"
        },
        "private": true,
        "dependencies": {
          "@angular/animations": "^4.0.0",
          "@angular/common": "^4.0.0",
          "@angular/compiler": "^4.0.0",
          "@angular/core": "^4.0.0",
          "@angular/forms": "^4.0.0",
          "@angular/http": "^4.0.0",
          "@angular/platform-browser": "^4.0.0",
          "@angular/platform-browser-dynamic": "^4.0.0",
          "@angular/platform-server": "^4.0.0",
          "@angular/router": "^4.0.0",
          "angular-2-local-storage": "^1.0.1",
          "angular2-busy": "^2.0.4",
          "angular2-emoji-picker": "1.4.3",
          "angular2-infinite-scroll": "^0.3.5",
          "angular2-social-login": "^3.0.1",
          "core-js": "^2.4.1",
          "enhanced-resolve": "^3.3.0",
          "google-maps": "^3.2.1",
          "jquery": "^3.2.1",
          "lg-autoplay": "^1.0.4",
          "lg-fullscreen": "^1.0.1",
          "lg-hash": "^1.0.1",
          "lg-pager": "^1.0.2",
          "lg-share": "^1.0.2",
          "lg-thumbnail": "^1.0.3",
          "lg-video": "^1.0.1",
          "lg-zoom": "^1.0.4",
          "lightgallery": "^1.3.9",
          "lightgallery.js": "^1.0.1",
          "ng-cli": "^0.7.0",
          "ng2-bootstrap": "^1.6.3",
          "ng2-go-top-button": "^2.0.8",
          "ng2-google-place-autocomplete": "^1.4.2",
          "ng2-toastr": "^4.0.1",
          "ng2-validation": "^4.2.0",
          "ngx-bootstrap": "^2.0.0-beta.8",
          "ngx-pagination": "^3.0.1",
          "rxjs": "^5.1.0",
          "time-ago-pipe": "^1.2.1",
          "zone.js": "^0.8.4"
        },
        "devDependencies": {
          "@angular/cli": "^1.5.0",
          "@angular/compiler-cli": "^4.0.0",
          "@types/jasmine": "2.5.38",
          "@types/node": "~6.0.60",
          "codelyzer": "~2.0.0",
          "jasmine-core": "~2.5.2",
          "jasmine-spec-reporter": "~3.2.0",
          "karma": "~1.4.1",
          "karma-chrome-launcher": "~2.1.1",
          "karma-cli": "~1.0.1",
          "karma-coverage-istanbul-reporter": "^0.2.0",
          "karma-jasmine": "~1.1.0",
          "karma-jasmine-html-reporter": "^0.2.2",
          "protractor": "~5.1.0",
          "ts-node": "~2.0.0",
          "tslint": "~4.5.0",
          "typescript": "~2.2.0",
          "webpack": "^3.8.1"
        }
      }

这是我的tsconfigapp.json:

   {
      "extends": "../tsconfig.json",
      "compilerOptions": {
        "outDir": "../out-tsc/app",
        "module": "es2015",
        "baseUrl": "",
        "types": []
      },
      "exclude": [
        "server.ts",
        "test.ts",
        "**/*.spec.ts"
      ]
    }

这是我的tsconfig.json

         {
              "compileOnSave": false,
              "compilerOptions": {
                "outDir": "./dist/out-tsc",
                "baseUrl": "src",
                "sourceMap": true,
                "declaration": false,
                "moduleResolution": "node",
                "emitDecoratorMetadata": true,
                "experimentalDecorators": true,
                "target": "es5",
                "typeRoots": [
                  "node_modules/@types"
                ],
                "lib": [
                  "es2016",
                  "dom"
                ]
              },
              "angularCompilerOptions": {                          

                "genDir": "./dist/ngfactory",
                "entryModule": "./src/app/app.module#AppModule"
              }
            }

我被卡住了,我在互联网上冲浪,没有完美的解决方案。

请建议我如何解决此错误。

错误是:enter image description here

angular npm universal
1个回答
0
投票

尝试添加此:

{ BsModalRef } from 'ngx-bootstrap'; 

而不是这个:

{ BsModalRef } from './bs-modal-ref.service';
© www.soinside.com 2019 - 2024. All rights reserved.