question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
jpthirumalaicommented, Oct 10, 2019

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

0reactions
CsibiNorbertcommented, Sep 1, 2020

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR: Cannot read property 'unshift' of undefined i'm getting ...
I found a solution. After trying different ways for fixing this bug, I found that when you execute the command ng add @ng-toolkit/universal,...
Read more >
ng-toolkit/universal ERROR: Cannot read property 'unshift' of ...
ng-toolkit/universal ERROR : Cannot read property 'unshift' of undefined ... 'unshift' of undefined i'm getting this error when adding SSR to ...
Read more >
Fixed the error “cannot read property 'unshift' of undefined ...
Fixed the error “cannot read property 'unshift' of undefined” while executing ng add @ng-toolkit/universal using the steps:.
Read more >
TypeError: Cannot read property 'unshift' of undefined AngularJS
I'm working on this new AngularJS project with ngStorage (localStorage) and not quite sure why I'm getting the message below. I get this ......
Read more >
angular-universal-pwa - Bountysource
I'm getting this error when I am trying to run "ng add @ng-toolkit/serverless --provider aws" on a new Angular 11.0.1 project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found