maciejtreder / ng-toolkit

:star: Angular tool-box! Start your PWA in two steps! Add Serverless support for existing projects and much more
https://www.angular-universal-pwa.maciejtreder.com
MIT License
1.12k stars 156 forks source link

I ran this ng add @ng-toolkit/universal giving error #761

Open shafqatjan opened 4 years ago

shafqatjan commented 4 years ago

Ran ng add @ng-toolkit/universal and these are my dependencies:

 "dependencies": {
    "@angular/animations": "~8.0.1",
    "@angular/common": "~8.0.1",
    "@angular/compiler": "~8.0.1",
    "@angular/core": "~8.0.1",
    "@angular/forms": "~8.0.1",
    "@angular/platform-browser": "~8.0.1",
    "@angular/platform-browser-dynamic": "~8.0.1",
    "@angular/platform-server": "~8.0.1",
    "@angular/router": "~8.0.1",
    "@ng-toolkit/universal": "^1.1.21",
    "@nguniversal/express-engine": "^8.1.1",
    "@nguniversal/module-map-ngfactory-loader": "8.1.1",
    "express": "^4.15.2",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },

Got this error:

Skipping installation: Package already installed
INFO: Project property is set to 'angular-8-jwt-authentication-example'.
ERROR: Cannot read property 'unshift' of undefined
ERROR: If you think that this error shouldn't occur, please fill up bug report here: https://github.com/maciejtreder/ng-toolkit/issues/new
INFO: stacktrace has been sent to tracking system.
Nothing to be done.
ryaneghrari commented 4 years ago

Hey I believe I am having the same issue:

ng add @ng-toolkit/universal
[bugsnag] Loaded!
ERROR: Cannot find module '@schematics/angular/utility/workspace'
ERROR: If you think that this error shouldn't occur, please fill up bug report here: https://github.com/maciejtreder/ng-toolkit/issues/new
INFO: stacktrace has been sent to tracking system.
Nothing to be done.

My dependencies are as follows:

"dependencies": {
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "^7.2.0",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "@ng-toolkit/universal": "^8.0.3",
    "@ngmodule/material-carousel": "^0.5.1",
    "@ngx-lite/json-ld": "^0.6.2",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "ng-animate-scroll": "^7.1.0",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  }

Let me know if there's anything else I can look into to help out.

KingDarBoja commented 4 years ago

@ryaneghrari I think it is related to the Angular version as (haven't checked it) the @schematics/angular/utility/workspace wasn't available in Angular 7. Try upgrading to Angualr 8 and try again.

Cheers!

ryaneghrari commented 4 years ago

@KingDarBoja Hey thanks a bunch, I had a feeling that was the case and so I upgraded to 8.2

"dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^7.2.0",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/platform-server": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@ng-toolkit/universal": "^8.0.3",
    "@ngmodule/material-carousel": "^0.6.0",
    "@nguniversal/common": "8.1.0",
    "@nguniversal/express-engine": "v8.2.6",
    "@nguniversal/module-map-ngfactory-loader": "v8.2.6",
    "@ngx-lite/json-ld": "^0.6.2",
    "core-js": "^2.5.4",
    "domino": "^2.1.3",
    "express": "^4.15.2",
    "hammerjs": "^2.0.8",
    "ng-animate-scroll": "^7.1.0",
    "rxjs": "~6.5.4",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  }

However now I am experiencing a strange error if I run npm run build:prod

chunk {3} polyfills-es5.fefa72e12b2a2d6ef7f2.js (polyfills-es5) 123 kB [initial] [rendered]
chunk {2} polyfills-es2015.2987770fde9daa1d8a2e.js (polyfills) 36.4 kB [initial] [rendered]
chunk {1} main-es2015.b3da8384c2438b2cb2a4.js (main) 991 kB [initial] [rendered]
chunk {1} main-es5.b3da8384c2438b2cb2a4.js (main) 1.08 MB [initial] [rendered]
chunk {0} runtime-es2015.edb2fcf2778e7bf1d426.js (runtime) 1.45 kB [entry] [rendered]
chunk {0} runtime-es5.edb2fcf2778e7bf1d426.js (runtime) 1.45 kB [entry] [rendered]
chunk {4} styles.cebfb5301b31fd975487.css (styles) 668 kB [initial] [rendered]
Date: 2020-01-31T14:24:15.398Z - Hash: bc19758f0f6bb2230169 - Time: 28261ms

WARNING in budgets, maximum exceeded for initial. Budget 2 MB was exceeded by 195 kB.
Hash: d6b58000d9191ef649c9
Time: 475ms
Built at: 01/31/2020 9:24:22 AM
  Asset      Size  Chunks  Chunk Names
main.js  3.76 KiB       0  main
Entrypoint main = main.js
chunk    {0} main.js (main) 28 bytes [entry] [rendered]

ERROR in Could not resolve module @angular/core   <----------------- seems to be an issue
npm ERR! code ELIFECYCLE
npm ERR! errno 1