jfcere / ngx-malihu-scrollbar

Angular 2+ scrollbar customization using Malihu jQuery Custom Scrollbar plugin
https://jfcere.github.io/ngx-malihu-scrollbar
MIT License
58 stars 17 forks source link

ReferenceError: $ is not defined after using angular universal #42

Closed RaveenaPanjeta closed 5 years ago

RaveenaPanjeta commented 5 years ago

error :

ERROR ReferenceError: $ is not defined
    at MalihuScrollbarDirective.initElements (/var/www/html/game-ssr/dist/server.js:127055:15)
    at MalihuScrollbarDirective.ngAfterViewInit (/var/www/html/game-ssr/dist/server.js:127046:14)
    at callProviderLifecycles (/var/www/html/game-ssr/dist/server.js:13408:18)
    at callElementProvidersLifecycles (/var/www/html/game-ssr/dist/server.js:13379:13)
    at callLifecycleHooksChildrenFirst (/var/www/html/game-ssr/dist/server.js:13363:17)
    at checkAndUpdateView (/var/www/html/game-ssr/dist/server.js:14496:5)
    at callViewAction (/var/www/html/game-ssr/dist/server.js:14838:21)
    at execComponentViewsAction (/var/www/html/game-ssr/dist/server.js:14770:13)
    at checkAndUpdateView (/var/www/html/game-ssr/dist/server.js:14494:5)
    at callViewAction (/var/www/html/game-ssr/dist/server.js:14838:21)

it shows no error on 'ng serve' and if i run dist. but shows the above error when run using server side rendering (by angular universal)

my packege.json is

{
  "name": "game",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "webpack-dev-server --port=4200",
    "build": " webpack",
    "test": "karma start ./karma.conf.js",
    "lint": "ng lint",
    "e2e": "protractor ./protractor.conf.js",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "build:universal": "npm run build:client-and-server-bundles && npm run webpack:server",
    "serve:universal": "node dist/server.js",
    "build:client-and-server-bundles": "ng build --prod && ng build --prod --app 1 --output-hashing=false",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
    "compile_ng_circle_progress": "babel node_modules/ng-circle-progress -d node_modules/ng-circle-progress --presets @babel/preset-env",
    "postinstall": "npm run compile_ng_circle_progress"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/platform-server": "~5.0.0",
    "@angular/router": "~5.0.0",
    "@angular/upgrade": "~5.0.0",
    "@nguniversal/express-engine": "^5.0.0",
    "@nguniversal/module-map-ngfactory-loader": "^5.0.0",
    "@ngx-loading-bar/core": "^1.6.0",
    "@ngx-loading-bar/http-client": "^1.6.0",
    "@ngx-loading-bar/router": "^1.6.0",
    "@ngx-utils/cookies": "^3.0.2",
    "angular-in-memory-web-api": "~0.5.0",
    "angular2-draggable": "^1.4.0",
    "bootstrap": "^4.1.0",
    "cookie-parser": "^1.4.3",
    "core-js": "^2.4.1",
    "jquery": "^3.3.1",
    "localstorage-polyfill": "^1.0.1",
    "ng-circle-progress": "^1.0.0",
    "ngx-cookie-service": "^1.0.10",
    "ngx-malihu-scrollbar": "^1.3.2",
    "ngx-mask": "^2.7.3",
    "ngx-order-pipe": "^2.0.1",
    "ngx-tooltip": "0.0.9",
    "ngx-webstorage": "^2.0.1",
    "popper.js": "^1.14.3",
    "rxjs": "^5.5.0",
    "ts-loader": "^3.1.1",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular-devkit/core": "0.3.2",
    "@angular/cli": "~1.7.3",
    "@angular/compiler-cli": "~5.0.0",
    "@angular/language-service": "~5.0.0",
    "@babel/cli": "^7.1.2",
    "@babel/core": "^7.1.2",
    "@babel/preset-env": "^7.1.0",
    "@ngtools/webpack": "1.10.2",
    "@types/jasmine": "~2.8.0",
    "@types/jasminewd2": "^2.0.3",
    "@types/node": "^6.0.45",
    "autoprefixer": "^7.2.3",
    "circular-dependency-plugin": "^4.2.1",
    "codelyzer": "^4.0.1",
    "copy-webpack-plugin": "~4.4.1",
    "file-loader": "^1.1.5",
    "grunt": "~0.4.5",
    "grunt-contrib-clean": "^1.1.0",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-exec": "^3.0.0",
    "grunt-http": "^2.3.1",
    "grunt-string-replace": "^1.3.1",
    "html-webpack-plugin": "^2.29.0",
    "istanbul-instrumenter-loader": "^3.0.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.3",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "less-loader": "^4.0.5",
    "lodash": "^4.16.2",
    "phantomjs-prebuilt": "^2.1.7",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.10",
    "postcss-url": "^7.1.2",
    "protractor": "~5.1.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.19.1",
    "stylus-loader": "^3.0.1",
    "ts-node": "^3.3.0",
    "tslint": "^3.15.1",
    "typescript": "2.4.2",
    "uglifyjs-webpack-plugin": "^1.2.7",
    "url-loader": "^0.6.2",
    "webpack": "~3.11.0",
    "webpack-dev-server": "~2.11.0"
  }
}
jfcere commented 5 years ago

Hi @RaveenaPanjeta,

Did you include JQuery and MalihuCustomScrollbar CSS and JS files to your angular.json file (or webpack config file)?

Do you have a repository I can investigate?

RaveenaPanjeta commented 5 years ago

Thanks for the reply. Issue is solved . The malihu-scrollbar is applied to the div only if the platform is browser. Doing it does not give any error on server side. Once again thanks for the reply.

jfcere commented 5 years ago

Ok thanks for the feedback, maybe I could do that verification directly in the library.