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

ng add @ng-toolkit/universal throws ERROR: Cannot read property 'unshift' of undefined #683

Closed stanislavromanov closed 4 years ago

stanislavromanov commented 5 years ago

I'm submitting a...


[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

In package


[ ] @ng-toolkit/init
[ ] @ng-toolkit/serverless
[x] @ng-toolkit/universal
[ ] @ng-toolkit/pwa
[ ] @ng-toolkit/firebug

Current behavior

It does not work at all. ng add @ng-toolkit/universal is throwing ERROR: Cannot read property 'unshift' of undefined. No files are generated, package.json is not changed etc.

Expected behavior

It should work?

Minimal reproduction of the problem with instructions

  1. ng new mycoolapp
  2. cd mycoolapp
  3. ng add @ng-toolkit/universal

Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 8.3.3
Node: 10.16.3
OS: darwin x64
Angular: 8.2.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.3
@angular-devkit/build-angular     0.803.3
@angular-devkit/build-optimizer   0.803.3
@angular-devkit/build-webpack     0.803.3
@angular-devkit/core              8.3.3
@angular-devkit/schematics        8.3.3
@angular/cli                      8.3.3
@ngtools/webpack                  8.3.3
@schematics/angular               8.3.3
@schematics/update                0.803.3
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

- Node version: v10.16.3
- Platform:  Mac

Others:

➜  Desktop ng new mycoolapp
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? SCSS   [ https://sass-lang.com/documentation/syntax#scss                ]
CREATE mycoolapp/README.md (1026 bytes)
CREATE mycoolapp/.editorconfig (246 bytes)
CREATE mycoolapp/.gitignore (631 bytes)
CREATE mycoolapp/angular.json (3705 bytes)
CREATE mycoolapp/package.json (1283 bytes)
CREATE mycoolapp/tsconfig.json (543 bytes)
CREATE mycoolapp/tslint.json (1988 bytes)
CREATE mycoolapp/browserslist (429 bytes)
CREATE mycoolapp/karma.conf.js (1021 bytes)
CREATE mycoolapp/tsconfig.app.json (270 bytes)
CREATE mycoolapp/tsconfig.spec.json (270 bytes)
CREATE mycoolapp/src/favicon.ico (948 bytes)
CREATE mycoolapp/src/index.html (295 bytes)
CREATE mycoolapp/src/main.ts (372 bytes)
CREATE mycoolapp/src/polyfills.ts (2838 bytes)
CREATE mycoolapp/src/styles.scss (80 bytes)
CREATE mycoolapp/src/test.ts (642 bytes)
CREATE mycoolapp/src/assets/.gitkeep (0 bytes)
CREATE mycoolapp/src/environments/environment.prod.ts (51 bytes)
CREATE mycoolapp/src/environments/environment.ts (662 bytes)
CREATE mycoolapp/src/app/app-routing.module.ts (246 bytes)
CREATE mycoolapp/src/app/app.module.ts (393 bytes)
CREATE mycoolapp/src/app/app.component.scss (0 bytes)
CREATE mycoolapp/src/app/app.component.html (25530 bytes)
CREATE mycoolapp/src/app/app.component.spec.ts (1107 bytes)
CREATE mycoolapp/src/app/app.component.ts (214 bytes)
CREATE mycoolapp/e2e/protractor.conf.js (810 bytes)
CREATE mycoolapp/e2e/tsconfig.json (214 bytes)
CREATE mycoolapp/e2e/src/app.e2e-spec.ts (642 bytes)
CREATE mycoolapp/e2e/src/app.po.ts (262 bytes)

> fsevents@1.2.9 install /Users/stan/Desktop/mycoolapp/node_modules/@angular/compiler-cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/stan/Desktop/mycoolapp/node_modules/@angular/compiler-cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> fsevents@1.2.9 install /Users/stan/Desktop/mycoolapp/node_modules/karma/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/stan/Desktop/mycoolapp/node_modules/karma/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> fsevents@1.2.9 install /Users/stan/Desktop/mycoolapp/node_modules/watchpack/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/stan/Desktop/mycoolapp/node_modules/watchpack/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> fsevents@1.2.9 install /Users/stan/Desktop/mycoolapp/node_modules/webpack-dev-server/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/stan/Desktop/mycoolapp/node_modules/webpack-dev-server/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> core-js@2.6.9 postinstall /Users/stan/Desktop/mycoolapp/node_modules/babel-runtime/node_modules/core-js
> node scripts/postinstall || echo "ignore"

> core-js@3.2.1 postinstall /Users/stan/Desktop/mycoolapp/node_modules/core-js
> node scripts/postinstall || echo "ignore"

> core-js@2.6.9 postinstall /Users/stan/Desktop/mycoolapp/node_modules/karma/node_modules/core-js
> node scripts/postinstall || echo "ignore"

> @angular/cli@8.3.3 postinstall /Users/stan/Desktop/mycoolapp/node_modules/@angular/cli
> node ./bin/postinstall/script.js

added 1455 packages from 1071 contributors and audited 18838 packages in 64.976s
found 0 vulnerabilities

    Successfully initialized git.
➜  Desktop cd mycoolapp
➜  mycoolapp git:(master) ng add @ng-toolkit/universal
Installing packages for tooling via npm.
npm WARN deprecated bugsnag@2.4.3: All projects should upgrade to our universal JS notifier: "@bugsnag/js". See https://github.com/bugsnag/bugsnag-js/blob/master/UPGRADING.md for more details.
npm WARN deprecated core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.

> fsevents@1.2.9 install /Users/stan/Desktop/mycoolapp/node_modules/@ng-toolkit/_utils/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/stan/Desktop/mycoolapp/node_modules/@ng-toolkit/_utils/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> fsevents@1.2.9 install /Users/stan/Desktop/mycoolapp/node_modules/@ng-toolkit/universal/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download
[fsevents] Success: "/Users/stan/Desktop/mycoolapp/node_modules/@ng-toolkit/universal/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> @ng-toolkit/universal@1.1.21 postinstall /Users/stan/Desktop/mycoolapp/node_modules/@ng-toolkit/universal
> node postinstall.js

Do you ❤️ @ng-toolkit?

Star it on GitHub!
https://github.com/maciejtreder/ng-toolkit

Become a donor:
 > https://www.angular-universal-pwa.maciejtreder.com/donors

+ @ng-toolkit/universal@1.1.21
added 183 packages from 96 contributors and audited 36197 packages in 28.255s
found 0 vulnerabilities

Installed packages for tooling via npm.
INFO: Project property is set to 'mycoolapp'.
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.
➜  mycoolapp git:(master) ✗ npm run build:ssr

npm ERR! missing script: build:ssr
npm ERR!
npm ERR! Did you mean this?
npm ERR!     build

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/stan/.npm/_logs/2019-09-05T10_30_14_569Z-debug.log
➜  mycoolapp git:(master) ✗ npm run build:prerender

npm ERR! missing script: build:prerender

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/stan/.npm/_logs/2019-09-05T10_30_20_291Z-debug.log

Pirateoncrew commented 5 years ago

in your package.json there will be script build:ssr script is not defined so you are getting unshift error try to run 'npm run build:ssr' you will get the same error.

stanislavromanov commented 5 years ago

in your package.json there will be script build:ssr script is not defined so you are getting unshift error

I don't have this script in package.json. AFAIK the command ng add @ng-toolkit/universal must create the script.

KingDarBoja commented 5 years ago

Same happening here, tried to create a project from scratch and add @ng-toolkit/universal as stated by the docs but getting the same output error.

Enviroment

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 8.3.3
Node: 10.16.3
OS: win32 x64
Angular: 8.2.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.3
@angular-devkit/build-angular     0.803.3
@angular-devkit/build-optimizer   0.803.3
@angular-devkit/build-webpack     0.803.3
@angular-devkit/core              8.3.3
@angular-devkit/schematics        8.3.3
@angular/cli                      8.3.3
@ngtools/webpack                  8.3.3
@schematics/angular               8.3.3
@schematics/update                0.803.3
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2
jpthirumalai commented 5 years ago

Fixed the error "cannot read property 'unshift' of undefined" while executing ng add @ng-toolkit/universal using the steps: Step 1:@ng-toolkit/universal, in package.json appears the new dependency, (might be with older version dependency but in 1.1.2 version "@ng-toolkit/universal": "1.1.21",) Step 2:Delete universal folder in the location node_modules\@ng-toolkit Step 3: Change the line in package.json to 7.1.2:: "@ng-toolkit/universal": "7.1.2", Step 4: now run the command ng add @ng-toolkit/universal@7.1.2

KingDarBoja commented 4 years ago

Closing it for housekeeping reason.

Please continue on #695.

SwapnilSoni1999 commented 4 years ago

its still there #716

CsibiNorbert commented 4 years ago

Hi guys, I`m a little bit confused in regards with the .Net Core Web API side.

When I'm installing this package, and then i do a build --prod in order to get the files inside the wwwroot inside the .NET CORE web API project and then i press start, it doesnt do anything. What Im missing from here? I guess somehow i would need to run the server like ng run server or something.

Who I would integrate this with .NET CORE Web API backend?