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.

Prerender Unable to extract routes from application.

See original GitHub issue

When I am trying to run “npm run prerender” without lazy-routing it’s working but when I am trying with lazy-routing it’s giving me ERORR Unable to extract routes from application.

Working with

const routes: Routes = [ { path: '', component:HomeComponent } } ];

Not working with this

const routes: Routes = [ { path: '', loadChildren: () => import('./home/home.module').then(m => m.HomeModule) } ];

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
wagnermacielcommented, Sep 12, 2020

@alcfeoh Yep. If you have already run ng add @nguniversal/express-engine, it should be located at the bottom of angular.json. By default it looks like this

"prerender": {
          "builder": "@nguniversal/builders:prerender",
          "options": {
            "browserTarget": "something:build:production",
            "serverTarget": "something:server:production",
            "routes": [
              "/"
            ]
          },
          "configurations": {
            "production": {}
          }
        }

You can switch out "routes" for "routesFile" and give it the relative path to a file with newline separated routes instead of an array. E.g.

  "routesFile: "./routes.txt",
2reactions
jmartinpersonalcommented, Oct 7, 2020

I am having an issue that seems similar. Setting the “guessRoutes”: false fixed the initial error but I also get: Prerendering 9 route(s) to C:\development\blog-universal\dist\blog-universal\browser An unhandled exception occurred: spawn ENAMETOOLONG See “C:\Users\jeffm\AppData\Local\Temp\ng-NwusJ7\angular-errors.log” for further details. npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file C:\WINDOWS\system32\cmd.exe npm ERR! errno ENOENT npm ERR! blog-universal@0.0.0 prerender: ng run blog-universal:prerender npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the blog-universal@0.0.0 prerender script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\jeffm\AppData\Roaming\npm-cache_logs\2020-10-07T15_57_06_582Z-debug.log. Not finding much information, any help would be appreciated

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to extract routes from application while pre rendering ...
I'm trying to implement pre rendering in angular app version 11. After running the command npm run prerender I'm getting the below error...
Read more >
Angular v9 & Universal: SSR and prerendering out of the box!
The routing modules of your application are analyzed and the routes found are prerendered. To prerender the routes of your application, just run ......
Read more >
Prerender Unable to extract routes from application.
When I am trying to run "npm run prerender" without lazy-routing it's working but when I am trying with lazy-routing it's giving me...
Read more >
Prerendering static pages - Angular
Angular Universal lets you prerender the pages of your application. ... guessRoutes, Whether builder should extract routes and guess which paths to render....
Read more >
Problem running Build command: npm run prerender - Support
... message 2:56:29 PM: Command failed with exit code 1: npm run prerender ... run spotbie:prerender 11:47:01 PM: Unable to extract routes from...
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