0
votes

I can't run my angular app on amazon ec2. When I execute ng serve or ng serve -c stage with environment.stage.ts configuration, i'm getting errors as shown on the screenshot below. The error does not appear when run locally on my pc and project is compiled without errors.

The version of rxjs is 5.5.5.

Angular, angular-cli and node version also below.

enter image description here

ERROR in ./node_modules/@angular/router/esm5/router.js Module not found: Error: Can't resolve 'rxjs/BehaviorSubject' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@angular/router/esm5' ERROR in ./node_modules/@agm/core/services/google-maps-api-wrapper.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services' ERROR in ./node_modules/@agm/core/services/managers/data-layer-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@agm/core/services/managers/marker-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@agm/core/services/managers/info-window-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@agm/core/services/managers/polyline-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@agm/core/services/managers/circle-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@agm/core/services/managers/kml-layer-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@agm/core/services/managers/polygon-manager.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@agm/core/services/managers' ERROR in ./node_modules/@angular/core/esm5/core.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@angular/core/esm5' ERROR in ./node_modules/@angular/http/esm5/http.js Module not found: Error: Can't resolve 'rxjs/Observable' in '/home/ubuntu/b2s_dev/b2s_v2_web/node_modules/@angular/http/esm5' ℹ 「wdm」: Failed to compile.

BR,

3
Please post your text errors as text. Corporate proxies make it impossible for some people to see your errors. - user4676340
can you share how you write your rxjs imports? - Javier Aviles
are you sure you ran "npm install" on the ec2 instance? - Hoff
Yes I'm running npm install and here is how I'm import rxjs: import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/catch'; import 'rxjs/add/observable/throw'; - Игор Ташевски
Can you add your package.json to the question please? - user184994

3 Answers

0
votes

try to import rxjs only without observables

0
votes

{
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "start-stage": "ng serve --env=stage",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build:universal:prod": "ng build --prod && ng build --prod --app 1 --output-hashing=false && cpy ./server.js ./dist",
    "serve:universal:prod": "npm run build:universal:prod && cd dist && node server",
    "compile_@agm_core": "babel node_modules/@agm/core -d node_modules/@agm/core --presets es2015",
    "postinstall": "npm run compile_@agm_core"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.2",
    "@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.2.7",
    "@angular/router": "^5.0.0",
    "@nguniversal/express-engine": "^5.0.0-beta.6",
    "babel-cli": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "core-js": "^2.4.1",
    "moment": "^2.20.1",
    "ng2-nouislider": "^1.7.7",
    "ngx-disqus": "^2.3.7",
    "nouislider": "^10.1.0",
    "rxjs": "^5.5.5",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.3",
    "@angular/cli": "^6.1.3",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/language-service": "^5.0.0",
    "@types/googlemaps": "^3.30.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "cpy-cli": "^1.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }
}
0
votes

Use this command to install rxjs compact that will install the latest version of rxjs that is compatible with the Angular version that you are using.

npm install --save rxjs-compat