It worked with version 8
ng add @nguniversal/[email protected] --client-project={{project_id}}
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Cannot read property 'some' of undefined
$ ng version
Angular CLI: 9.1.9
Node: 12.18.0
OS: linux x64
Angular: 9.1.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.9
@angular-devkit/build-angular 0.901.9
@angular-devkit/build-optimizer 0.901.9
@angular-devkit/build-webpack 0.901.9
@angular-devkit/core 9.1.9
@angular-devkit/schematics 9.1.9
@angular/cdk 9.1.3
@angular/cli 9.1.9
@angular/fire 5.4.2
@angular/material 9.1.3
@ngtools/webpack 9.1.9
@nguniversal/common 9.1.1
@nguniversal/express-engine 9.1.1
@schematics/angular 9.1.9
@schematics/update 0.901.9
rxjs 6.5.5
typescript 3.9.5
webpack 4.43.0
Can you try ng add @nguniversal/express-engine?
Are there any further logs that you can provide?
It's already added
Cannot read property 'some' of undefined
This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
I had the same issue wen was trying to migrate from v9 to v10.
So what I've done, just replicated my project structure (I am using workspace with a multiple projects and the shared library) with the latest cli and then just copy pasted all the code and some TS custom options from the v9 project.
Just make all working this way.
I got that error too.
After doing some modifications of your code here is what I found out (in my case):
The error comes from /universal/modules/common/schematics/utils/utils.ts
Specifically in the addInitialNavigation function.
It seems that you are looking for properties of the existingOptions.
existingOptions.properties.some
This is the some that breaks.
Just before the exception happens, I printed the existingOptions.escapedText which showed (in my case):
routerOptions
After doing a lookup in my project, I found only 1 place with this.
In my app-routing.module.ts
Here is it:
```import { NgModule } from '@angular/core';
import { Routes, RouterModule, ExtraOptions } from '@angular/router';
const routes: Routes = [
{
path: '',
pathMatch: 'full',
loadChildren: () => import('./home/home.module').then(m => m.HomeModule)
},
{
path: 'home',
loadChildren: () => import('./home/home.module').then(m => m.HomeModule)
},
{
path: 'download',
loadChildren: () => import('./download/download.module').then(m => m.DownloadModule)
},
// otherwise redirect to home
{
path: '**',
redirectTo: ''
}
];
const routerOptions: ExtraOptions = {
scrollPositionRestoration: 'enabled',
anchorScrolling: 'enabled'
};
@NgModule({
imports: [
RouterModule.forRoot(routes, routerOptions)
],
exports: [RouterModule]
})
export class AppRoutingModule { }
It looks like your are not handling the **ExtraOptions** properly, or it might be the way I declared it.
If I roll back everything, remove my **routerOptions** (no options at all), then the whole process completes without any problem.
I hope this helps you fix the issue properly.
---
As for a quick'n'dirty fix:
1. Open **node_modules\@nguniversal\common\schematics\utils\utils.js**
2. in **function addInitialNavigation(node)** replace:
`if (existingOptions && existingOptions.properties.some(`
with
`if (existingOptions && existingOptions.properties && existingOptions.properties.some(`
3. replace:
`const routerOptions = existingOptions ? ts.updateObjectLiteral(`
with
`const routerOptions = existingOptions && existingOptions.properties ? ts.updateObjectLiteral(`
4. run **ng add @nguniversal/express-engine**
After that the migration completed
Skipping installation: Package already installed
CREATE server.ts (2017 bytes)
UPDATE package.json (3621 bytes)
UPDATE angular.json (5887 bytes)
UPDATE src/app/app-routing.module.ts (2657 bytes)
√ Packages installed successfully.
Note: my **app-routing.module.ts** was wrong after that as my routerOptions were not used anymore.
And instead it declared an **initialNavigation** setting.
Most probably it is caused by the way I _fixed_ the problem,
So I just rolled back the changes for **app-routing.module.ts**, and integrated the **initialNavigation: 'enabled'**
const routerOptions: ExtraOptions = {
scrollPositionRestoration: 'enabled',
anchorScrolling: 'enabled',
initialNavigation: 'enabled'
};
@NgModule({
imports: [
RouterModule.forRoot(routes, routerOptions)
],
exports: [RouterModule]
})
export class AppRoutingModule { }
```
Most helpful comment
I got that error too.
After doing some modifications of your code here is what I found out (in my case):
The error comes from /universal/modules/common/schematics/utils/utils.ts
Specifically in the addInitialNavigation function.
It seems that you are looking for properties of the existingOptions.
existingOptions.properties.someThis is the some that breaks.
Just before the exception happens, I printed the existingOptions.escapedText which showed (in my case):
routerOptionsAfter doing a lookup in my project, I found only 1 place with this.
In my app-routing.module.ts
Here is it:
```import { NgModule } from '@angular/core';
import { Routes, RouterModule, ExtraOptions } from '@angular/router';
const routes: Routes = [
{
path: '',
pathMatch: 'full',
loadChildren: () => import('./home/home.module').then(m => m.HomeModule)
},
{
path: 'home',
loadChildren: () => import('./home/home.module').then(m => m.HomeModule)
},
{
path: 'download',
loadChildren: () => import('./download/download.module').then(m => m.DownloadModule)
},
// otherwise redirect to home
{
path: '**',
redirectTo: ''
}
];
const routerOptions: ExtraOptions = {
scrollPositionRestoration: 'enabled',
anchorScrolling: 'enabled'
};
@NgModule({
imports: [
RouterModule.forRoot(routes, routerOptions)
],
exports: [RouterModule]
})
export class AppRoutingModule { }
Skipping installation: Package already installed
CREATE server.ts (2017 bytes)
UPDATE package.json (3621 bytes)
UPDATE angular.json (5887 bytes)
UPDATE src/app/app-routing.module.ts (2657 bytes)
√ Packages installed successfully.
const routerOptions: ExtraOptions = {
scrollPositionRestoration: 'enabled',
anchorScrolling: 'enabled',
initialNavigation: 'enabled'
};
@NgModule({
imports: [
RouterModule.forRoot(routes, routerOptions)
],
exports: [RouterModule]
})
export class AppRoutingModule { }
```