问:
How to fix bootstrap Error in angular ? What is going wrong
I am not sure why I am getting following error.

```<code>ERROR in node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,34): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(27,44): error TS1144: '{' or ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(28,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(29,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(30,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(31,1): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,20): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,21): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,74): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,24): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,25): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,41): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,51): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,43): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,50): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,29): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,35): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,69): error TS1005: '>' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,72): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,74): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,75): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(95,55): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(119,58): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(122,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(123,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,28): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,58): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,76): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,105): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,126): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,162): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,196): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,224): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,239): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,256): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,270): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,295): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,330): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,15): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,21): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,24): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,46): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,52): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,25): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,43): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,21): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,27): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,33): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,32): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,42): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,48): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,19): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,25): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(138,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,17): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,23): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,46): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(141,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(142,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(143,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(144,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(145,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(146,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(147,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(148,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(149,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(150,1): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(7,39): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,67): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,76): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,79): error TS1109: Expression expected.
node_modules/@ngrx/store/src/models.d.ts(7,95): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(8,12): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,3): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,10): error TS1005: ')' expected.
node_modules/@ngrx/store/src/models.d.ts(37,58): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(37,98): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(39,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(45,85): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(45,125): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(47,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(47,64): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(48,59): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(48,99): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(50,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(59,43): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(59,67): error TS1005: ',' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,83): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,126): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,69): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,112): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,79): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,120): error TS1109: Expression expected.
</code>```

Below is my angular.json

```<code>{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "AllowMeClientAngular": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/AllowMeClientAngular",
            "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/nouislider/distribute/nouislider.min.css",
              "node_modules/angular-calendar/scss/angular-calendar.scss",
              "node_modules/dragula/dist/dragula.css",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/videogular2/fonts/videogular.css",
              "node_modules/@swimlane/ngx-datatable/release/index.css",
              "node_modules/@swimlane/ngx-datatable/release/assets/icons.css",
              "node_modules/sweetalert2/dist/sweetalert2.min.css",
              "src/assets/css/prism.min.css",
              "src/assets/css/wizard.css",
              "src/assets/css/quill.snow.css",
              "src/assets/css/quill.bubble.css",
              "src/assets/css/hopscotch.css",
              "src/assets/css/demo.css",
              "src/assets/sass/app.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.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
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "AllowMeClientAngular:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "AllowMeClientAngular:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "AllowMeClientAngular: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": [

            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.min.js"
            ],
            "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/**"
            ]
          }
        }
      }
    },
    "AllowMeClientAngular-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "AllowMeClientAngular:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "AllowMeClientAngular:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "AllowMeClientAngular"
}
</code>```

Below is package.json

```<code>{
  "name": "allow-me-client-angular",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "^6.0.3",
    "@angular/cdk": "^6.4.0",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/material": "^6.4.0",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "@material/form-field": "^0.37.1",
    "@ng-bootstrap/ng-bootstrap": "^5.3.0",
    "@ngrx/store": "^8.6.0",
    "@ngx-translate/core": "^12.1.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-datatable": "^16.0.3",
    "angular-calendar": "^0.28.2",
    "bootstrap": "^4.4.1",
    "core-js": "^2.5.4",
    "jquery": "^3.4.1",
    "ng-chartist": "^4.1.0",
    "ng-pick-datetime": "^6.0.10",
    "ng2-dragula": "^2.1.1",
    "ng2-smart-table": "^1.5.0",
    "ngx-bootstrap": "^3.0.1",
    "ngx-password-toggle": "^1.0.3",
    "ngx-show-hide-password": "^1.2.4",
    "ngx-toastr": "^12.0.0",
    "ngx-webstorage": "^2.0.1",
    "node-sass": "^4.13.1",
    "nouislider": "^14.1.1",
    "rxjs": "^6.0.0",
    "sweetalert2": "^9.7.2",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@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.0",
    "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"
  }
}
</code>```

Can someone just explain what this error mean so that I can look for some solution. The issue is I not able to figure out what is exact issue.

答:
Try by putting it in your angular.json file in this manner-

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css"
]

Body:
I am not sure why I am getting following error.

ERROR in node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,34): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(27,44): error TS1144: '{' or ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(28,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(29,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(30,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(31,1): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,20): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,21): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,74): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,24): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,25): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,41): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,51): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,43): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,50): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,29): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,35): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,69): error TS1005: '>' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,72): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,74): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,75): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(95,55): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(119,58): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(122,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(123,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,28): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,58): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,76): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,105): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,126): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,162): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,196): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,224): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,239): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,256): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,270): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,295): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,330): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,15): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,21): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,24): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,46): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,52): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,25): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,43): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,21): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,27): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,33): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,32): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,42): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,48): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,19): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,25): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(138,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,17): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,23): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,46): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(141,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(142,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(143,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(144,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(145,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(146,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(147,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(148,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(149,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(150,1): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(7,39): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,67): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,76): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,79): error TS1109: Expression expected.
node_modules/@ngrx/store/src/models.d.ts(7,95): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(8,12): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,3): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,10): error TS1005: ')' expected.
node_modules/@ngrx/store/src/models.d.ts(37,58): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(37,98): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(39,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(45,85): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(45,125): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(47,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(47,64): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(48,59): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(48,99): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(50,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(59,43): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(59,67): error TS1005: ',' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,83): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,126): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,69): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,112): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,79): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,120): error TS1109: Expression expected.

Below is my angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "AllowMeClientAngular": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/AllowMeClientAngular",
            "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/nouislider/distribute/nouislider.min.css",
              "node_modules/angular-calendar/scss/angular-calendar.scss",
              "node_modules/dragula/dist/dragula.css",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/videogular2/fonts/videogular.css",
              "node_modules/@swimlane/ngx-datatable/release/index.css",
              "node_modules/@swimlane/ngx-datatable/release/assets/icons.css",
              "node_modules/sweetalert2/dist/sweetalert2.min.css",
              "src/assets/css/prism.min.css",
              "src/assets/css/wizard.css",
              "src/assets/css/quill.snow.css",
              "src/assets/css/quill.bubble.css",
              "src/assets/css/hopscotch.css",
              "src/assets/css/demo.css",
              "src/assets/sass/app.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.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
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "AllowMeClientAngular:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "AllowMeClientAngular:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "AllowMeClientAngular: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": [

            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.min.js"
            ],
            "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/**"
            ]
          }
        }
      }
    },
    "AllowMeClientAngular-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "AllowMeClientAngular:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "AllowMeClientAngular:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "AllowMeClientAngular"
}

Below is package.json

{
  "name": "allow-me-client-angular",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "^6.0.3",
    "@angular/cdk": "^6.4.0",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/material": "^6.4.0",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "@material/form-field": "^0.37.1",
    "@ng-bootstrap/ng-bootstrap": "^5.3.0",
    "@ngrx/store": "^8.6.0",
    "@ngx-translate/core": "^12.1.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-datatable": "^16.0.3",
    "angular-calendar": "^0.28.2",
    "bootstrap": "^4.4.1",
    "core-js": "^2.5.4",
    "jquery": "^3.4.1",
    "ng-chartist": "^4.1.0",
    "ng-pick-datetime": "^6.0.10",
    "ng2-dragula": "^2.1.1",
    "ng2-smart-table": "^1.5.0",
    "ngx-bootstrap": "^3.0.1",
    "ngx-password-toggle": "^1.0.3",
    "ngx-show-hide-password": "^1.2.4",
    "ngx-toastr": "^12.0.0",
    "ngx-webstorage": "^2.0.1",
    "node-sass": "^4.13.1",
    "nouislider": "^14.1.1",
    "rxjs": "^6.0.0",
    "sweetalert2": "^9.7.2",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@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.0",
    "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"
  }
}

Can someone just explain what this error mean so that I can look for some solution. The issue is I not able to figure out what is exact issue.


来源: stackexchange

问:
Generating PDF and Microsoft Word files in Ruby on Rails
I want to build a web app that will allow, based on answering questions from a series of prompts from users, to generate a report in Microsoft Word and/or PDF format. I would like the output of the report to be configured in the actual code, where the end result will not have to be altered by an user. Is that possible using Ruby and the Rails framework?</p>

答: It is possible, check out RailsCasts 78, 153 and 220 for complete examples.</p>

ContentLicense: CC BY-SA 3.0


问:
Split bash command into several reusable pieces
How can I split a command that uses pipes into different pieces?

I have the following working bash command:

```<code>RESULT=$(find "/path/to/releases" -maxdepth 0 -type d -print0 | xargs -r -0 ls -1 -t | tail -n 1)
</code>```

I would rather have the pipes split up into multiple variables like so, so I can reuse RESULT1 or RESULT2 somewhere else:

```<code>RESULT1=$(find "/path/to/releases" -maxdepth 0 -type d -print0)

if [ -n ${RESULT1} ]; then
  RESULT2=${RESULT1} | xargs -r -0 ls -1 -t
  RESULT3=${RESULT2} | tail -n 1
]
</code>```

Is this possible?

Update: The reason I also want to split things up is because I want to check first if the first part actually finds something before proceeding to the next pipe.

Update #2: Solved it like this; Used some examples above to make it easier to explain my problem. Here's the actual code.

```<code>DEPLOY_PATH="/data/www"
KEEP_RELEASES=3
function cleanup() {
      RELEASES=()
      OLDEST_RELEASE=

      for item in "${DEPLOY_PATH}"/releases/* ; do
        [[ -L ${item} || ! -d ${item} ]] && continue
        [[ -z ${OLDEST_RELEASE} || ${item} -ot ${OLDEST_RELEASE} ]] && OLDEST_RELEASE=${item}
        RELEASES+=("${item}")
      done

      if [ "${#RELEASES[@]}" -gt 0 ] && [ "${#RELEASES[@]}" -gt "${KEEP_RELEASES}" ]; then
        rm -rf "${DEPLOY_PATH}"/releases/$(basename "${OLDEST_RELEASE}")
        cleanup
      fi
}
</code>```

To bad that chaining with "find" and pipes likes xargs is not always the best choice. Imo it makes my script bigger when using a regular bash array.

答:
Yes, It's possible:

RESULT1=$(find "/path/to/releases" -maxdepth 0 -type d)
RESULT2=$(echo "$RESULT1" | xargs -r ls -1 -t)
RESULT3=$(echo "$RESULT2" | tail -n 1)
```

ContentLicense: CC BY-SA 4.0

Body:
How can I split a command that uses pipes into different pieces?

I have the following working bash command:

RESULT=$(find "/path/to/releases" -maxdepth 0 -type d -print0 | xargs -r -0 ls -1 -t | tail -n 1)

I would rather have the pipes split up into multiple variables like so, so I can reuse RESULT1 or RESULT2 somewhere else:

RESULT1=$(find "/path/to/releases" -maxdepth 0 -type d -print0)

if [ -n ${RESULT1} ]; then
  RESULT2=${RESULT1} | xargs -r -0 ls -1 -t
  RESULT3=${RESULT2} | tail -n 1
]

Is this possible?

Update: The reason I also want to split things up is because I want to check first if the first part actually finds something before proceeding to the next pipe.

Update #2: Solved it like this; Used some examples above to make it easier to explain my problem. Here's the actual code.

DEPLOY_PATH="/data/www"
KEEP_RELEASES=3
function cleanup() {
      RELEASES=()
      OLDEST_RELEASE=

      for item in "${DEPLOY_PATH}"/releases/* ; do
        [[ -L ${item} || ! -d ${item} ]] && continue
        [[ -z ${OLDEST_RELEASE} || ${item} -ot ${OLDEST_RELEASE} ]] && OLDEST_RELEASE=${item}
        RELEASES+=("${item}")
      done

      if [ "${#RELEASES[@]}" -gt 0 ] && [ "${#RELEASES[@]}" -gt "${KEEP_RELEASES}" ]; then
        rm -rf "${DEPLOY_PATH}"/releases/$(basename "${OLDEST_RELEASE}")
        cleanup
      fi
}

To bad that chaining with "find" and pipes likes xargs is not always the best choice. Imo it makes my script bigger when using a regular bash array.


问:
List all matches to a "one or more" regex
I am trying to tokenize organize chemical names, i.e. split "hexane" into ['hex', 'an', 'e'], its constituent parts.

At the core of this issue is: how do I list ~all~ matches to a "one or more" regex, rather than just the last match to that regex?

I am testing by using the following code:

```<code>    print("Regex:", reg)
    print("Findall:", re.findall(reg, name))
    print("Finditer", [item.groups() for item in list(re.finditer(reg, name))])
    print("Search:", re.search(reg, name).groups())
    print("Split", re.split(reg, name))
    print("Match", re.match(reg, name).groups())
</code>```

In all of my tests, name = "hexane". This should parse out to ['hex', 'an', 'e']. My attempted regexes follow the pattern of "\A({many groups added here, separated by bars})\Z", where the many groups are a subset of the prefixes and suffixes available to organic chemicals.

When using a regex without parentheses on each section of my regex, I get this output:

```<code>Regex: \A((-|nonadeca|heptadeca|tetradec|imine|hept|heptadec|benzene|cyclo|oate|tetradeca|hex|yn|octa|phenyl|arsine|yl|dodec|e|eth|meth|pentadec|nona|phosphino|octadec|di|formyl|arsino|oct|oxo|tridec|penta|pent|dodeca|hydroxy|hexadec|hexa|ol|an|oyl|ether|non|trideca|prop|undec|hepta|pentadeca|nonadec|amine|tri|but|carbonyl|deca|en|amino|undeca|hexadeca|thiol|oxy|tetra|dec|carboxy|chloro|mercapto|iodo|fluoro|octadeca|imino|bromo|al|phosphine|carboxylicacid|amide|one|amido|oicacid)+)\Z
Findall: [('hexane', 'e')]
Finditer [('hexane', 'e')]
Search: ('hexane', 'e')
Split ['', 'hexane', 'e', '']
Match ('hexane', 'e')
</code>```

This shows that the regex must have correctly found the ['hex', 'an', 'e'] split, as no other combination of parts will provide a comprehensive \A-STUFF_IN_HERE-\Z match. However, none of the results provide the molecule split into its component parts for my use.

Putting parentheses around each part gives the following result:

```<code>Regex: \A(-|(tetradec)|(thiol)|(phenyl)|(arsino)|(carbonyl)|(one)|(e)|(fluoro)|(ol)|(ether)|(eth)|(trideca)|(hex)|(iodo)|(nonadeca)|(non)|(pent)|(al)|(octa)|(octadec)|(di)|(undeca)|(arsine)|(tri)|(cyclo)|(prop)|(nona)|(dodec)|(phosphine)|(yn)|(but)|(an)|(heptadeca)|(carboxy)|(imine)|(hept)|(octadeca)|(amide)|(imino)|(deca)|(dodeca)|(oct)|(hydroxy)|(bromo)|(undec)|(pentadeca)|(tetra)|(hexadec)|(benzene)|(phosphino)|(hexa)|(tridec)|(mercapto)|(dec)|(oyl)|(oxy)|(meth)|(penta)|(amido)|(oicacid)|(amine)|(yl)|(nonadec)|(tetradeca)|(hexadeca)|(carboxylicacid)|(amino)|(chloro)|(pentadec)|(en)|(hepta)|(heptadec)|(formyl)|(oate)|(oxo))+\Z
Findall: [('e', '', '', '', '', '', '', 'e', '', '', '', '', '', 'hex', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'an', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')]
Finditer [('e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)]
Search: ('e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)
Split ['', 'e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, '']
Match ('e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)
</code>```

This again shows that the ['hex', 'an', 'e'] parts are being successfully parsed, but it does not provide those parts for me in an easy list.

Note:
There are ambiguities such as that between the "hex" and "hexa" prefixes that make a simple left-to-right re.split or re.findall without the \A\Z specifier unfeasible. Either precedence would go to "hex" in all cases, in which case "hexapentyldecane" would parse as ["hex", ?????], being broken by the trailing "a", or precedence would go to "hexa", so that "hexane" would parse as ["hexa", ???], broken by the trailing "n".

答:
When you don't know ahead of time how many match groups there will be, a single regex can't capture them all in a convenient structure. But you can loop or split just fine.

```<code>import re

string = 'hexane'
while True:
    oldstring = string
    string = re.sub(r'\A(-|nonadeca|heptadeca|tetradec|imine|hept|heptadec|benzene|cyclo|oate|tetradeca|hex|yn|octa|phenyl|arsine|yl|dodec|e|eth|meth|pentadec|nona|phosphino|octadec|di|formyl|arsino|oct|oxo|tridec|penta|pent|dodeca|hydroxy|hexadec|hexa|ol|an|oyl|ether|non|trideca|prop|undec|hepta|pentadeca|nonadec|amine|tri|but|carbonyl|deca|en|amino|undeca|hexadeca|thiol|oxy|tetra|dec|carboxy|chloro|mercapto|iodo|fluoro|octadeca|imino|bromo|al|phosphine|carboxylicacid|amide|one|amido|oicacid)', '', string)
    if not string:
        print(oldstring)
        break
    print(oldstring[0:-len(string)])
</code>```

The above is not particularly elegant, but should at least get you started.

Body:
I am trying to tokenize organize chemical names, i.e. split "hexane" into ['hex', 'an', 'e'], its constituent parts.

At the core of this issue is: how do I list ~all~ matches to a "one or more" regex, rather than just the last match to that regex?

I am testing by using the following code:

    print("Regex:", reg)
    print("Findall:", re.findall(reg, name))
    print("Finditer", [item.groups() for item in list(re.finditer(reg, name))])
    print("Search:", re.search(reg, name).groups())
    print("Split", re.split(reg, name))
    print("Match", re.match(reg, name).groups())

In all of my tests, name = "hexane". This should parse out to ['hex', 'an', 'e']. My attempted regexes follow the pattern of "\A({many groups added here, separated by bars})\Z", where the many groups are a subset of the prefixes and suffixes available to organic chemicals.

When using a regex without parentheses on each section of my regex, I get this output:

Regex: \A((-|nonadeca|heptadeca|tetradec|imine|hept|heptadec|benzene|cyclo|oate|tetradeca|hex|yn|octa|phenyl|arsine|yl|dodec|e|eth|meth|pentadec|nona|phosphino|octadec|di|formyl|arsino|oct|oxo|tridec|penta|pent|dodeca|hydroxy|hexadec|hexa|ol|an|oyl|ether|non|trideca|prop|undec|hepta|pentadeca|nonadec|amine|tri|but|carbonyl|deca|en|amino|undeca|hexadeca|thiol|oxy|tetra|dec|carboxy|chloro|mercapto|iodo|fluoro|octadeca|imino|bromo|al|phosphine|carboxylicacid|amide|one|amido|oicacid)+)\Z
Findall: [('hexane', 'e')]
Finditer [('hexane', 'e')]
Search: ('hexane', 'e')
Split ['', 'hexane', 'e', '']
Match ('hexane', 'e')

This shows that the regex must have correctly found the ['hex', 'an', 'e'] split, as no other combination of parts will provide a comprehensive \A-STUFF_IN_HERE-\Z match. However, none of the results provide the molecule split into its component parts for my use.

Putting parentheses around each part gives the following result:

Regex: \A(-|(tetradec)|(thiol)|(phenyl)|(arsino)|(carbonyl)|(one)|(e)|(fluoro)|(ol)|(ether)|(eth)|(trideca)|(hex)|(iodo)|(nonadeca)|(non)|(pent)|(al)|(octa)|(octadec)|(di)|(undeca)|(arsine)|(tri)|(cyclo)|(prop)|(nona)|(dodec)|(phosphine)|(yn)|(but)|(an)|(heptadeca)|(carboxy)|(imine)|(hept)|(octadeca)|(amide)|(imino)|(deca)|(dodeca)|(oct)|(hydroxy)|(bromo)|(undec)|(pentadeca)|(tetra)|(hexadec)|(benzene)|(phosphino)|(hexa)|(tridec)|(mercapto)|(dec)|(oyl)|(oxy)|(meth)|(penta)|(amido)|(oicacid)|(amine)|(yl)|(nonadec)|(tetradeca)|(hexadeca)|(carboxylicacid)|(amino)|(chloro)|(pentadec)|(en)|(hepta)|(heptadec)|(formyl)|(oate)|(oxo))+\Z
Findall: [('e', '', '', '', '', '', '', 'e', '', '', '', '', '', 'hex', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'an', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')]
Finditer [('e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)]
Search: ('e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)
Split ['', 'e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, '']
Match ('e', None, None, None, None, None, None, 'e', None, None, None, None, None, 'hex', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'an', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)

This again shows that the ['hex', 'an', 'e'] parts are being successfully parsed, but it does not provide those parts for me in an easy list.

Note:
There are ambiguities such as that between the "hex" and "hexa" prefixes that make a simple left-to-right re.split or re.findall without the \A\Z specifier unfeasible. Either precedence would go to "hex" in all cases, in which case "hexapentyldecane" would parse as ["hex", ?????], being broken by the trailing "a", or precedence would go to "hexa", so that "hexane" would parse as ["hexa", ???], broken by the trailing "n".

Body:
When you don't know ahead of time how many match groups there will be, a single regex can't capture them all in a convenient structure. But you can loop or split just fine.

import re

string = 'hexane'
while True:
    oldstring = string
    string = re.sub(r'\A(-|nonadeca|heptadeca|tetradec|imine|hept|heptadec|benzene|cyclo|oate|tetradeca|hex|yn|octa|phenyl|arsine|yl|dodec|e|eth|meth|pentadec|nona|phosphino|octadec|di|formyl|arsino|oct|oxo|tridec|penta|pent|dodeca|hydroxy|hexadec|hexa|ol|an|oyl|ether|non|trideca|prop|undec|hepta|pentadeca|nonadec|amine|tri|but|carbonyl|deca|en|amino|undeca|hexadeca|thiol|oxy|tetra|dec|carboxy|chloro|mercapto|iodo|fluoro|octadeca|imino|bromo|al|phosphine|carboxylicacid|amide|one|amido|oicacid)', '', string)
    if not string:
        print(oldstring)
        break
    print(oldstring[0:-len(string)])

The above is not particularly elegant, but should at least get you started.


问:
mouseover element not working using protractor
I have a directive that produces the following html structure:

```<code><div class="popover ng-isolate-scope" ng-mouseover="toggle(true)" ng-mouseleave="toggle(false)" popover="" label="hover time!" trigger-class="button" content-class="specialContentClass">
  <span id="thing" class="popover-trigger button">hover time!</span>
  <div ng-transclude="" ng-show="show" class="popover-content ng-hide">
    <div class="ng-scope">Popover content </div>
  </div>
</div>
</code>```

The code works fine and the popover content is correctly shown when you mouseover manually using a browser.

I'm trying to test the mouseover functionality with the following protractor test:

```<code> it('should display the popover-content on mouseover', function() {
     browser.get('http://localhost:9000/');
     browser.actions()
     .mouseMove(element(by.css('.popover')).find()).perform();
     expect(element(by.css('.popover-content'))
     .isDisplayed().toBeTruthy());
 });
</code>```

The test seems to run, the browser opens but I don't see the popup-content displaying before the browser then closes so I'm fairly sure the mousemove bit isn't working for some reason. The following is then output in the terminal:

```<code>launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
ycompu:angular ycompu$
</code>```

I've read the documentation and using browser is definitely the right way to approach this test. I'm at a loss as the syntax looks correct to me.

答:
use this method pass the locater to the method this is working fine

```<code>mouseHover: function (locator) {
        return browser.actions().mouseMove(locator).perform();
    },
</code>```

Body:
I have a directive that produces the following html structure:

  hover time!

Popover content

The code works fine and the popover content is correctly shown when you mouseover manually using a browser.

I'm trying to test the mouseover functionality with the following protractor test:

 it('should display the popover-content on mouseover', function() {
     browser.get('http://localhost:9000/');
     browser.actions()
     .mouseMove(element(by.css('.popover')).find()).perform();
     expect(element(by.css('.popover-content'))
     .isDisplayed().toBeTruthy());
 });

The test seems to run, the browser opens but I don't see the popup-content displaying before the browser then closes so I'm fairly sure the mousemove bit isn't working for some reason. The following is then output in the terminal:

launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
ycompu:angular ycompu$

I've read the documentation and using browser is definitely the right way to approach this test. I'm at a loss as the syntax looks correct to me.

Body:
use this method pass the locater to the method this is working fine

mouseHover: function (locator) {
        return browser.actions().mouseMove(locator).perform();
    },


问:
Type hinting. How to hint that object passed to a function must have some method/attribute access?
please, see an example which uses numpy doctstring for type hinting:

def my_function(obj):
    """Do some work.

    Parameters
    ----------
        obj : Any class with `do_work()` method
    Returns
    -------
    None
    """
    time.sleep(5)
```

I'm wondering whether there is a way to tell a caller that function expects object which has do_work method? Is there a way to specify such type hints using python3/mypy type hinting or/and numpy docstrings?

答:
Define a Protocol

```<code>import typing

class Worker(typing.Protocol):
    def do_work(self):
        pass

class SomeWorker:
    def do_work(self):
        print("Working...")

def my_function(obj: Worker):
    obj.do_work()

x = SomeWorker()
my_function(x)  # This will type check; `SomeWorker` doesn't have to inherit from Worker
</code>```

Body:
please, see an example which uses numpy doctstring for type hinting:

def my_function(obj):
    """Do some work.

    Parameters
    ----------
        obj : Any class with `do_work()` method
    Returns
    -------
    None
    """
    time.sleep(5)

I'm wondering whether there is a way to tell a caller that function expects object which has do_work method? Is there a way to specify such type hints using python3/mypy type hinting or/and numpy docstrings?

Body:
Define a Protocol

import typing

class Worker(typing.Protocol):
    def do_work(self):
        pass

class SomeWorker:
    def do_work(self):
        print("Working...")

def my_function(obj: Worker):
    obj.do_work()

x = SomeWorker()
my_function(x)  # This will type check; `SomeWorker` doesn't have to inherit from Worker


问:
SyntaxError: Unexpected token '<' when dockerizing react app
I have a react project with Webpack which I'm trying to dockerize it following this article.

Dockerfile:

```<code>FROM node:12.14.1

RUN npm install webpack -g

WORKDIR /tmp
COPY package.json /tmp/
RUN npm config set registry http://registry.npmjs.org/ && npm install

WORKDIR /usr/app
COPY . /usr/app/
RUN cp -a /tmp/node_modules /usr/app/

RUN webpack

ENV NODE_ENV=production
ENV PORT=4000

CMD [ "/usr/local/bin/node", "--experimental-modules", "./src/index.js" ]

EXPOSE 4000
</code>```

docker-compose.yml:

```<code>ex_dashboard:
  build: .
  ports:
  - "80:4000"
  volumes:
  - .:/usr/app/:rw
  environment:
  - NODE_ENV=dev
  command: >
    sh -c '
      if test -d node_modules;
      then
        echo node_modules_exists ;
      else
        cp -a /tmp/node_modules /usr/app/dashboard;
      fi &&
      npm install &&
      /usr/local/bin/node --experimental-modules ./src/index.js
    '
</code>```

When I run docker-compose up, everything goes well until I encounter this error:

```<code>ex_dashboard_1  | (node:18) ExperimentalWarning: The ESM module loader is experimental.
ex_dashboard_1  | file:///usr/app/src/index.js:9
ex_dashboard_1  |   <Provider store={store}>
ex_dashboard_1  |   ^
ex_dashboard_1  |
ex_dashboard_1  | SyntaxError: Unexpected token '<'
ex_dashboard_1  |     at Loader.moduleStrategy (internal/modules/esm/translators.js:66:18)
ex_dashboard_1  |     at async link (internal/modules/esm/module_job.js:37:21)
</code>```

The whole project works well if I just run it by npm start or build it by npm run build. But I don't know why this happens in docker container.

Here is package.json:

```<code>{
  "name": "explore_dashboard",
  "version": "1.0.0",
  "description": "A dashboard for the Explore project",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "cross-env NODE_ENV=development webpack-dev-server --hot",
    "build": "cross-env NODE_ENV=production webpack",
    "lint": "eslint ./src",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://gitlab.basalam.dev/data/explore_dashboard.git"
  },
  "author": "Gh.Sherafati",
  "license": "ISC",
  "resolve": {
    "alias": {
      "react-dom": "@hot-loader/react-dom"
    }
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/plugin-transform-runtime": "^7.8.3",
    "@babel/preset-env": "^7.8.4",
    "@babel/preset-react": "^7.8.3",
    "babel-eslint": "^10.0.3",
    "babel-loader": "^8.0.6",
    "cross-env": "^7.0.0",
    "css-loader": "^3.4.2",
    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-loader": "^3.0.3",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.18.0",
    "eslint-plugin-react-hooks": "^1.7.0",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.13.1",
    "sass-loader": "^8.0.2",
    "style-loader": "^1.1.3",
    "webpack": "^4.41.5",
    "webpack-cli": "^3.3.10",
    "webpack-dev-server": "^3.10.2"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.27",
    "@fortawesome/free-solid-svg-icons": "^5.12.1",
    "@fortawesome/react-fontawesome": "^0.1.8",
    "@hot-loader/react-dom": "^16.11.0",
    "@types/react": "^16.9.19",
    "axios": "^0.19.2",
    "react": "^16.12.0",
    "react-beautiful-dnd": "^12.2.0",
    "react-dom": "^16.12.0",
    "react-hot-loader": "^4.12.19",
    "react-redux": "^7.1.3",
    "redux": "^4.0.5",
    "redux-saga": "^1.1.3"
  }
}
</code>```

And webpack.config.js:

```<code>const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const { env } = process;

module.exports = {
  entry: './src/index.js',
  mode: env.NODE_ENV,
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader', 'eslint-loader'],
      },
      {
        test: /\.s[ac]ss$/i,
        use: [
          // Creates `style` nodes from JS strings
          'style-loader',
          // Translates CSS into CommonJS
          'css-loader',
          // Compiles Sass to CSS
          'sass-loader',
        ],
      },
    ],
  },
  resolve: {
    extensions: ['*', '.js', '.jsx'],
  },
  output: {
    path: path.join(__dirname, '/build'),
    publicPath: '/',
    filename: 'bundle.js',
  },
  plugins: [
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV) }),
    new HtmlWebpackPlugin({
      template: path.resolve('./src/index.html'),
    }),
  ],
  devServer: {
    contentBase: './build',
    hot: true,
  },
  devtool: env.NODE_ENV === 'development' ? 'cheap-module-eval-source-map' : undefined,
};
</code>```

Also index.js:

```<code>import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import store from './redux/store';
import App from './components/App';
import './scss/main.scss';

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('app'),
);

module.hot.accept();
</code>```

答:
In your docker-compose.yml file, delete the volumes: and the rather long-winded command:.

The important thing that’s going on here is that your index.js file actually includes JSX constructs that React uses; it’s not plain Javascript and node can’t run it directly.  In your Dockerfile you RUN webpack, which transpiles this into plain Javascript.  The volumes: overwrite all of this with whatever content is on your local system; that does not include a transpilation step, so you don’t have valid Javascript for Node to run.

(It might work to put an explicit call to webpack in that command:.  This assumes your host and container node_modules are compatible, and it is literally duplicating everything the Dockerfile does to build the image in the docker-compose.yml file.)

Nothing stops you from installing Node on your host system (if you don’t already have it), doing live development using the Webpack dev server, and then using Docker for a final packaging step.  That’s probably much more convenient than introducing an isolation system like Docker and then trying to work around all of its features to emulate a local development setup.

Body:
I have a react project with Webpack which I'm trying to dockerize it following this article.

Dockerfile:

FROM node:12.14.1

RUN npm install webpack -g

WORKDIR /tmp
COPY package.json /tmp/
RUN npm config set registry http://registry.npmjs.org/ && npm install

WORKDIR /usr/app
COPY . /usr/app/
RUN cp -a /tmp/node_modules /usr/app/

RUN webpack

ENV NODE_ENV=production
ENV PORT=4000

CMD [ "/usr/local/bin/node", "--experimental-modules", "./src/index.js" ]

EXPOSE 4000

docker-compose.yml:

ex_dashboard:
  build: .
  ports:
  - "80:4000"
  volumes:
  - .:/usr/app/:rw
  environment:
  - NODE_ENV=dev
  command: >
    sh -c '
      if test -d node_modules;
      then
        echo node_modules_exists ;
      else
        cp -a /tmp/node_modules /usr/app/dashboard;
      fi &&
      npm install &&
      /usr/local/bin/node --experimental-modules ./src/index.js
    '

When I run docker-compose up, everything goes well until I encounter this error:

ex_dashboard_1  | (node:18) ExperimentalWarning: The ESM module loader is experimental.
ex_dashboard_1  | file:///usr/app/src/index.js:9
ex_dashboard_1  |   <Provider store={store}>
ex_dashboard_1  |   ^
ex_dashboard_1  |
ex_dashboard_1  | SyntaxError: Unexpected token '<'
ex_dashboard_1  |     at Loader.moduleStrategy (internal/modules/esm/translators.js:66:18)
ex_dashboard_1  |     at async link (internal/modules/esm/module_job.js:37:21)

The whole project works well if I just run it by npm start or build it by npm run build. But I don't know why this happens in docker container.

Here is package.json:

{
  "name": "explore_dashboard",
  "version": "1.0.0",
  "description": "A dashboard for the Explore project",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "start": "cross-env NODE_ENV=development webpack-dev-server --hot",
    "build": "cross-env NODE_ENV=production webpack",
    "lint": "eslint ./src",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://gitlab.basalam.dev/data/explore_dashboard.git"
  },
  "author": "Gh.Sherafati",
  "license": "ISC",
  "resolve": {
    "alias": {
      "react-dom": "@hot-loader/react-dom"
    }
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/plugin-transform-runtime": "^7.8.3",
    "@babel/preset-env": "^7.8.4",
    "@babel/preset-react": "^7.8.3",
    "babel-eslint": "^10.0.3",
    "babel-loader": "^8.0.6",
    "cross-env": "^7.0.0",
    "css-loader": "^3.4.2",
    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-loader": "^3.0.3",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.18.0",
    "eslint-plugin-react-hooks": "^1.7.0",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.13.1",
    "sass-loader": "^8.0.2",
    "style-loader": "^1.1.3",
    "webpack": "^4.41.5",
    "webpack-cli": "^3.3.10",
    "webpack-dev-server": "^3.10.2"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.27",
    "@fortawesome/free-solid-svg-icons": "^5.12.1",
    "@fortawesome/react-fontawesome": "^0.1.8",
    "@hot-loader/react-dom": "^16.11.0",
    "@types/react": "^16.9.19",
    "axios": "^0.19.2",
    "react": "^16.12.0",
    "react-beautiful-dnd": "^12.2.0",
    "react-dom": "^16.12.0",
    "react-hot-loader": "^4.12.19",
    "react-redux": "^7.1.3",
    "redux": "^4.0.5",
    "redux-saga": "^1.1.3"
  }
}

And webpack.config.js:

const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const { env } = process;

module.exports = {
  entry: './src/index.js',
  mode: env.NODE_ENV,
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader', 'eslint-loader'],
      },
      {
        test: /\.s[ac]ss$/i,
        use: [
          // Creates `style` nodes from JS strings
          'style-loader',
          // Translates CSS into CommonJS
          'css-loader',
          // Compiles Sass to CSS
          'sass-loader',
        ],
      },
    ],
  },
  resolve: {
    extensions: ['*', '.js', '.jsx'],
  },
  output: {
    path: path.join(__dirname, '/build'),
    publicPath: '/',
    filename: 'bundle.js',
  },
  plugins: [
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV) }),
    new HtmlWebpackPlugin({
      template: path.resolve('./src/index.html'),
    }),
  ],
  devServer: {
    contentBase: './build',
    hot: true,
  },
  devtool: env.NODE_ENV === 'development' ? 'cheap-module-eval-source-map' : undefined,
};

Also index.js:

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import store from './redux/store';
import App from './components/App';
import './scss/main.scss';

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('app'),
);

module.hot.accept();


问:
List of functions: Apply additional argument only to those functions who can take it
I have a list of functions, most of which take the same additional argument (na.rm = TRUE).

I want to add a function which doesn't take this argument (length). Is it possible to apply the additional argument only to the functions which can take it? I thought of using ..., but I am not really sure how to apply it, and if this is possible at all.

I am using lapply, but happy with any options, also beyond base R.

x <- c(1:10,NA)

# working example only with functions that take the extra argument

show_stats <- function(x) {
  funs <- list(mean = mean, sd = sd)
  lapply(funs, function(f) f(x, na.rm = TRUE))
}
show_stats(x)
#> $mean
#> [1] 5.5
#>
#> $sd
#> [1] 3.02765

# sadly not working, because length() only takes one argument
show_stats <- function(x) {
  funs <- list(mean = mean, sd = sd, n = length)
  lapply(funs, function(f) f(x, na.rm = TRUE))
}

show_stats(x)
#> Error in f(x, na.rm = TRUE): 2 arguments passed to 'length' which requires 1
```

Created on 2020-02-16 by the reprex package (v0.3.0)

答:
1) The question is not clear on what is expected as output for length but if the question is how to remove the NAs regardless of whether the function takes an na.rm argument or not then just remove the NAs first.

```<code>show_stats2 <- function(x) {
  funs <- list(mean = mean, sd = sd, length = length)
  lapply(funs, function(f) f(na.omit(x)))
}
</code>```

2) Another possibility which allows the functions to have arbitrarily varying arguments is the following.  Each function is defined as a simple formula with whatever arguments are appropriate.  This uses fn$ from gsubfn to transform a formula to a function.`

```<code>library(gsubfn)
show_stats3 <- function(x) {
  funs <- list(mean = ~ mean(x, na.rm = TRUE),
               sd = ~ sd(x, na.rm = TRUE),
               length = ~ length(x))
  fn$lapply(funs, function(f) fn$identity(f)(x))
}
</code>```

3) Here is a variation of (2) which requires that you write the word function but is similarly flexible:

```<code>show_stats4 <- function(x) {
  funs <- list(mean = function(x) mean(x, na.rm = TRUE),
               sd = function(x) sd(x, na.rm = TRUE),
               length = length)
  lapply(funs, function(f) f(x))
}
</code>```

4) Yet another variation is to use Curry from the functional package:

```<code>library(functional)
show_stats5 <- function(x) {
  funs <- list(mean = Curry(mean, na.rm = TRUE),
               sd = Curry(sd, na.rm = TRUE),
               length = length)
  lapply(funs, function(f) f(x))
}
</code>```

Body:
I have a list of functions, most of which take the same additional argument (na.rm = TRUE).

I want to add a function which doesn't take this argument (length). Is it possible to apply the additional argument only to the functions which can take it? I thought of using ..., but I am not really sure how to apply it, and if this is possible at all.

I am using lapply, but happy with any options, also beyond base R.

x <- c(1:10,NA)

# working example only with functions that take the extra argument

show_stats <- function(x) {
  funs <- list(mean = mean, sd = sd)
  lapply(funs, function(f) f(x, na.rm = TRUE))
}
show_stats(x)
#> $mean
#> [1] 5.5
#>
#> $sd
#> [1] 3.02765

# sadly not working, because length() only takes one argument
show_stats <- function(x) {
  funs <- list(mean = mean, sd = sd, n = length)
  lapply(funs, function(f) f(x, na.rm = TRUE))
}

show_stats(x)
#> Error in f(x, na.rm = TRUE): 2 arguments passed to 'length' which requires 1

Created on 2020-02-16 by the reprex package (v0.3.0)

Body:
1) The question is not clear on what is expected as output for length but if the question is how to remove the NAs regardless of whether the function takes an na.rm argument or not then just remove the NAs first.

show_stats2 <- function(x) {
  funs <- list(mean = mean, sd = sd, length = length)
  lapply(funs, function(f) f(na.omit(x)))
}

2) Another possibility which allows the functions to have arbitrarily varying arguments is the following.  Each function is defined as a simple formula with whatever arguments are appropriate.  This uses fn$ from gsubfn to transform a formula to a function.`

library(gsubfn)
show_stats3 <- function(x) {
  funs <- list(mean = ~ mean(x, na.rm = TRUE),
               sd = ~ sd(x, na.rm = TRUE),
               length = ~ length(x))
  fn$lapply(funs, function(f) fn$identity(f)(x))
}

3) Here is a variation of (2) which requires that you write the word function but is similarly flexible:

show_stats4 <- function(x) {
  funs <- list(mean = function(x) mean(x, na.rm = TRUE),
               sd = function(x) sd(x, na.rm = TRUE),
               length = length)
  lapply(funs, function(f) f(x))
}

4) Yet another variation is to use Curry from the functional package:

library(functional)
show_stats5 <- function(x) {
  funs <- list(mean = Curry(mean, na.rm = TRUE),
               sd = Curry(sd, na.rm = TRUE),
               length = length)
  lapply(funs, function(f) f(x))
}


问:
UICollectionView is not reloading search results even with reloadData
I can get the search feature to filter out the results but it won't display those searched results on the iPhone emulator. It displays the results on the iPhone I have (iPhone 5) but not on the emulator. I don't know why they collection view is not updating while I type. The items in the array are being displayed because the I first navigate to that screen I can see them.

```<code>import UIKit

class BrowseViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UISearchBarDelegate {

    @IBOutlet weak var testCollectionView: UICollectionView!

    var Array = [Product]()
    var currentArray = [Product]() //update table

    private func setUpAnimals() {

        Array.append(Product(name: "Cheetos", price: "3.99", image:"1"))
        Array.append(Product(name: "Coca Cola", price: "2.29", image:"2"))
        Array.append(Product(name: "Red Bull", price: "3.79", image:"3"))
        Array.append(Product(name: "Doritos", price: "1.99", image:"4"))
        Array.append(Product(name: "Lays Barbecue", price: "1.89", image:"5"))
        Array.append(Product(name: "Skittles", price: "1.49", image:"6"))
        Array.append(Product(name: "Cheez It", price: "1.29", image:"7"))
        Array.append(Product(name: "Pringles", price: "3.49", image:"8"))
        Array.append(Product(name: "Lays", price: "1.89", image:"9"))
        Array.append(Product(name: "Fritos", price: "3.99", image:"10"))

        currentArray = Array

    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setUpAnimals()
        self.view.backgroundColor = UIColor.white
        let itemSize = UIScreen.main.bounds.width/3 - 3

        let layout = UICollectionViewFlowLayout()
        layout.sectionInset = UIEdgeInsets.init(top: 30, left: 0, bottom: 20, right: 0)
        layout.itemSize = CGSize (width: itemSize, height: itemSize)

        layout.minimumInteritemSpacing = 3
        layout.minimumLineSpacing = 3

        testCollectionView.collectionViewLayout = layout

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }

    // Number of views in the collection view

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return self.currentArray.count
    }

    //Populating the viewsc

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        // Shows Image
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! TestCollectionViewCell
        cell.testImageView.image = UIImage(named: currentArray[indexPath.row].image + ".jpg")
        cell.titleLabel.text = (self.currentArray[indexPath.row].name)
        cell.priceLabel.text = ("$" + self.currentArray[indexPath.row].price)

        return cell
    }

    // Search Bar
    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {

        currentArray = Array.filter({ Product -> Bool in
            switch searchBar.selectedScopeButtonIndex {
            case 0:
                if searchText.isEmpty { return true }
                return Product.name.lowercased().contains(searchText.lowercased())
            default:
                return false
            }
        })
        //self.testCollectionView.reloadData()
       DispatchQueue.main.async { [weak self] in
            self?.testCollectionView.reloadData()
        }

    }

    func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
        switch selectedScope {
        case 0:
            currentArray = Array

        default:
            break
        }
           DispatchQueue.main.async { [weak self] in
                     self?.testCollectionView.reloadData()
                 }

    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let VC = storyboard?.instantiateViewController(withIdentifier: "AddToCartViewController") as? AddToCartViewController
        VC?.image = UIImage(named: currentArray[indexPath.row].image + ".jpg")!
        VC?.name = (self.currentArray[indexPath.row].name)
        VC?.price = (self.currentArray[indexPath.row].price)
        self.navigationController?.pushViewController(VC!, animated: true)

    }

}
</code>```

答:
The issue is you didn't set a delegate so the search bar callback methods aren't called!

If you use SearchController, you need to add this line to viewDidLoad

```<code>navigationItem.searchController?.searchBar.delegate = self
</code>```

Otherwise, set searchBar delegate to it

```<code>searchBar.delegate = self
</code>```

Note: You should change Array name to a more descriptive name following Camel Case naming convention like filteredArray

Body:
I can get the search feature to filter out the results but it won't display those searched results on the iPhone emulator. It displays the results on the iPhone I have (iPhone 5) but not on the emulator. I don't know why they collection view is not updating while I type. The items in the array are being displayed because the I first navigate to that screen I can see them.

import UIKit

class BrowseViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UISearchBarDelegate {

    @IBOutlet weak var testCollectionView: UICollectionView!

    var Array = [Product]()
    var currentArray = [Product]() //update table

    private func setUpAnimals() {

        Array.append(Product(name: "Cheetos", price: "3.99", image:"1"))
        Array.append(Product(name: "Coca Cola", price: "2.29", image:"2"))
        Array.append(Product(name: "Red Bull", price: "3.79", image:"3"))
        Array.append(Product(name: "Doritos", price: "1.99", image:"4"))
        Array.append(Product(name: "Lays Barbecue", price: "1.89", image:"5"))
        Array.append(Product(name: "Skittles", price: "1.49", image:"6"))
        Array.append(Product(name: "Cheez It", price: "1.29", image:"7"))
        Array.append(Product(name: "Pringles", price: "3.49", image:"8"))
        Array.append(Product(name: "Lays", price: "1.89", image:"9"))
        Array.append(Product(name: "Fritos", price: "3.99", image:"10"))

        currentArray = Array

    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setUpAnimals()
        self.view.backgroundColor = UIColor.white
        let itemSize = UIScreen.main.bounds.width/3 - 3

        let layout = UICollectionViewFlowLayout()
        layout.sectionInset = UIEdgeInsets.init(top: 30, left: 0, bottom: 20, right: 0)
        layout.itemSize = CGSize (width: itemSize, height: itemSize)

        layout.minimumInteritemSpacing = 3
        layout.minimumLineSpacing = 3

        testCollectionView.collectionViewLayout = layout

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }

    // Number of views in the collection view

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return self.currentArray.count
    }

    //Populating the viewsc

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        // Shows Image
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! TestCollectionViewCell
        cell.testImageView.image = UIImage(named: currentArray[indexPath.row].image + ".jpg")
        cell.titleLabel.text = (self.currentArray[indexPath.row].name)
        cell.priceLabel.text = ("$" + self.currentArray[indexPath.row].price)

        return cell
    }

    // Search Bar
    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {

        currentArray = Array.filter({ Product -> Bool in
            switch searchBar.selectedScopeButtonIndex {
            case 0:
                if searchText.isEmpty { return true }
                return Product.name.lowercased().contains(searchText.lowercased())
            default:
                return false
            }
        })
        //self.testCollectionView.reloadData()
       DispatchQueue.main.async { [weak self] in
            self?.testCollectionView.reloadData()
        }

    }

    func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
        switch selectedScope {
        case 0:
            currentArray = Array

        default:
            break
        }
           DispatchQueue.main.async { [weak self] in
                     self?.testCollectionView.reloadData()
                 }

    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let VC = storyboard?.instantiateViewController(withIdentifier: "AddToCartViewController") as? AddToCartViewController
        VC?.image = UIImage(named: currentArray[indexPath.row].image + ".jpg")!
        VC?.name = (self.currentArray[indexPath.row].name)
        VC?.price = (self.currentArray[indexPath.row].price)
        self.navigationController?.pushViewController(VC!, animated: true)

    }

}

Body:
The issue is you didn't set a delegate so the search bar callback methods aren't called!

If you use SearchController, you need to add this line to viewDidLoad

navigationItem.searchController?.searchBar.delegate = self

Otherwise, set searchBar delegate to it

searchBar.delegate = self

Note: You should change Array name to a more descriptive name following Camel Case naming convention like filteredArray


问:
Bigquery: Extract data from an array of json
(This is an extension to this question, but my reputation is too low to comment or ask more questions on that topic...)

We work on bigquery, hence limited in importing packages or using other languages. And, as per the link above, js is a solution, but not what I'm looking for here. I implemented it in js, and it was too slow for our needs.

Suppose one of our columns is a string that look like this (array of json):

[{"location":[22.99902,66.000],"t":1},{"location":[55.32168,140.556],"t":2},{"location":[85.0002,20.0055],"t":3}]

I want to extract from the column the json for which "t":2

Where:

some columns don't have elements "t":2

Some columns have several elements "t":2

The number of json elements in each string can change

element "t":2 is not always in second position.

I don't know regexp well enough for this. We tried regexp_extract with  this pattern: r'(\{.*?\"t\":2.*?\})')), but that doesn't work. It extracts everything that precedes "t":2, including the json for "t":2. We only want the json of element "t":2.

Could you advise a regexp pattern that would work?

EDIT:

I have a preference for a solution that gives me 1 match. Suppose I have this string:
[{"location":[22.99902,66.000],"t":1},{"location":[55.32168,140.556],"t":2},{"location":[55.33,141.785],"t":2}],

I would prefer receiving only 1 answer, the first one.

In that case perhaps regexp is less appropriate, but I'm really not sure?

Body:
How about this:

(?<=\{)(?=.*?\"t\"\s*:\s*2).*?(?=\})

As seen here


问:
'Conda' is not recognized as internal or external command
I installed Anaconda3 4.4.0 (32 bit) on my Windows 7 Professional machine and imported NumPy and Pandas on Jupyter notebook so I assume Python was installed correctly. But when I type conda list and conda --version in command prompt, it says conda is not recognized as internal or external command.

I have set environment variable for Anaconda3; Variable Name: Path, Variable Value: C:\Users\dipanwita.neogy\Anaconda3

How do I make it work?

答: I have just launched anaconda-navigator and run the conda commands from there.</p>


问:
Emulator: queryCoreProfileSupport: swap interval not found
I get an error message when running avd.

Emulator: queryCoreProfileSupport: swap interval not found

答:
Had the same issue  on Ubuntu 18.04 with AMD GPU driver 19.50 after upgrading to kernel 5.3.0-28-generic. Full error for me was:

```<code>Emulator: queryCoreProfileSupport: swap interval not found
Emulator: : CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
</code>```

Not a proper solution, but a workaround would be uninstalling the amdgpu[-pro] driver:

```<code>$/usr/bin/amdgpu-uninstall
</code>```

Body:
Had the same issue  on Ubuntu 18.04 with AMD GPU driver 19.50 after upgrading to kernel 5.3.0-28-generic. Full error for me was:

Emulator: queryCoreProfileSupport: swap interval not found
Emulator: : CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

Not a proper solution, but a workaround would be uninstalling the amdgpu[-pro] driver:

$/usr/bin/amdgpu-uninstall