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.

Error on server side rendering

See original GitHub issue
[ *] Bug
[ ] Build issue
[ ] Feature request

Version info

Angular: 8.2.14
Angular CLI: 8.3.23
ngx-countup: "^7.3.0"

Description

On server side, when I try to render or prerender a page that include CountUpModule, I got this error:

exec error node dist/prerender: Error: Command failed: node dist/prerender D:\angular\node_modules\countup.js\dist\countUp.min.js:1 var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var i,a=1,s=arguments.length;a<s;a++)for(var n in i=arguments[a])Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n]);return t}).apply(this,arguments)},CountUp=function(){function t(t,i,a){var s=this;this.target=t,this.endVal=i,this.options=a,this.version=“2.0.4”,this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:“,”,decimal:“.”,prefix:“”,suffix:“”},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error=“”,this.startVal=0,this.paused=!0,this.count=function(t){s.startTime||(s.startTime=t);var i=t-s.startTime;s.remaining=s.duration-i,s.useEasing?s.countDown?s.frameVal=s.startVal-s.easingFn(i,0,s.startVal-s.endVal,s.duration)😒.frameVal=s.easingFn(i,s.startVal,s.endVal-s.startVal,s.duration)😒.countDown?s.frameVal=s.startVal-(s.startVal-s.endV

SyntaxError: Unexpected token ‘export’ at Module._compile (internal/modules/cjs/loader.js:891:18) at Object.Module._extensions…js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Module.require (internal/modules/cjs/loader.js:848:19) at require (internal/modules/cjs/helpers.js:74:18) at D:\angular\node_modules\ngx-countup\bundles\ngx-countup.umd.js:2:111 at Object.<anonymous> (D:\angular\node_modules\ngx-countup\bundles\ngx-countup.umd.js:5:2) at Module._compile (internal/modules/cjs/loader.js:955:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:991:10)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
inorganikcommented, Aug 1, 2020

Ok, so in the above mentioned project demonstrating using this package with SSR and prerendering, I am still not getting any errors, but in a separate project, I started to get the “Syntax error: unexpected token export” error and it is undeniably caused by es6 modules. I tried to make sure all the settings matched in the webpack.config file, tsconfig, etc. but the error still persisted on my other project.

And since I don’t know how to reliably configure an angular project with SSR to not get this error when using es6 modules, I changed ngx-countUp to use a UMD packaged version of CountUp.

So now, from version 7.3.2 on, you should not receive this error.

1reaction
inorganikcommented, Feb 5, 2020

No it’s ok… I was hitting errors with that command too, but I didn’t see the countUp error.

When I run that in your repo I get

> universal-demo@7.0.0 generate:prerender /Users/jamieperkins/Web-projects/GitHub/manzonif-angular-ssr
> node dist-server-express/prerender.js

Error: Cannot find module './dist-server/main.0c90f278407064dcd9f8'

Even though I see the file is there…

The fact that I am able to compile my typescript server code on my ssr demo repo makes me think it is not an issue with ngx-countUp.

Perhaps instead of using that starter project, you could use my ssr demo repo, since it works…

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How to properly render server-side errors in the ...
I've setup a simple Node/Express service that creates new bookmarks to a database. In my Bookmark schema, one of the fields, url, has ......
Read more >
Handling runtime errors when server side rendering with Next.js
When server side rendering, Our old friend Try … catch is a good replacement to the error boundary as it works expectedly on...
Read more >
Logging and error management best practices in SSR apps
Server -side rendering (SSR) is an application's ability to preload a website in the server before sending it to the client to be...
Read more >
React Server Side Rendering Errors
Hi,. I am using MDB React Pro v4.8.7. My team uses SSR for all of our websites but I have been getting errors...
Read more >
Error Handling | Server Server Side Rendering with React and ...
Error Handling Solution | Error Handling | Server Server Side Rendering with React and ReduxSubscribe ...
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