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:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
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.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
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…