glennreyes / react-countup

💫 A configurable React component wrapper around CountUp.js
https://tr8tk.csb.app/
MIT License
2k stars 131 forks source link

SyntaxError: Unexpected token 'export' #813

Closed shivam7207 closed 1 year ago

shivam7207 commented 1 year ago

In react-countup error is coming while trying to use it

output:

3:06:59 PM: /opt/build/repo/node_modules/countup.js/dist/countUp.min.js:1 3:06:59 PM: var t=function(){return t=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var a in i=arguments[n])Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a]);return t},t.apply(this,arguments)},i=function(){function i(i,n,s){var a=this;this.endVal=n,this.options=s,this.version=2.6.2,this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:,,decimal:.,prefix:,suffix:,enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error=,this.startVal=0,this.paused=!0,this.once=!1,this.count=function(t){a.startTime||(a.startTime=t);var i=t-a.startTime;a.remaining=a.duration-i,a.useEasing?a.countDown?a.frameVal=a.startVal-a.easingFn(i,0,a.startVal-a.endVal,a.duration):a.frameVal=a.easingFn(i,a.startVal,a.endVal-a.startVal,a.duration):a.frameVal=a.startVal+(a.endVal-a.startVal)(i/a.duration);var n=a.countDown?a.frameVal<a.endVal:a.frameVal>a.endVal;a.frameVal=n?a.endVal:a.frameVal,a.frameVal=Number(a.frameVal.toFixed(a.options.decimalPlaces)),a.printValue(a.frameVal),i<a.duration?a.rAF=requestAnimationFrame(a.count):null!==a.finalEndVal?a.update(a.finalEndVal):a.options.onCompleteCallback&&a.options.onCompleteCallback()},this.formatNumber=function(t){var i,n,s,e,o=t<0?-:;i=Math.abs(t).toFixed(a.options.decimalPlaces);var r=(i+=).split(.);if(n=r[0],s=r.length>1?a.options.decimal+r[1]:,a.options.useGrouping){e=;for(var l=3,h=0,u=0,p=n.length;u<p;++u)a.options.useIndianSeparators&&4===u&&(l=2,h=1),0!==u&&h%l==0&&(e=a.options.separator+e),h++,e=n[p-u-1]+e;n=e}return a.options.numerals&&a.options.numerals.length&&(n=n.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]})),s=s.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]}))),o+a.options.prefix+n+s+a.options.suffix},this.easeOutExpo=function(t,i,n,s){return n(1-Math.pow(2,-10t/s))1024/1023+i},this.options=t(t({},this.defaults),s),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(n),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,===this.options.separator&&(this.options.useGrouping=!1),this.el=string==typeof i?document.getElementById(i):i,this.el?this.printValue(this.startVal):this.error=[CountUp] target is null or undefined,undefined!=typeof window&&this.options.enableScrollSpy&&(this.error?console.error(this.error,i):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push((function(){return a.handleScroll(a)})),window.onscroll=function(){window.onScrollFns.forEach((function(t){return t()}))},this.handleScroll(this)))}return i.prototype.handleScroll=function(t){if(t&&window&&!t.once){var i=window.innerHeight+window.scrollY,n=t.el.getBoundingClientRect(),s=n.top+window.pageYOffset,a=n.top+n.height+window.pageYOffset;a<i&&a>window.scrollY&&t.paused?(t.paused=!1,setTimeout((function(){return t.start()}),t.options.scrollSpyDelay),t.options.scrollSpyOnce&&(t.once=!0)):(window.scrollY>a||s>i)&&!t.paused&&t.reset()}},i.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=t;var n=this.countDown?1:-1;this.endVal=t+nthis.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;null!==this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},i.prototype.start=function(t){this.error||(t&&(this.options.onCompleteCallback=t),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},i.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},i.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},i.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,null==this.finalEndVal&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},i.prototype.printValue=function(t){var i;if(this.el){var n=this.formattingFn(t);if(null===(i=this.options.plugin)||void 0===i?void 0:i.render)this.options.plugin.render(this.el,n);else if(INPUT===this.el.tagName)this.el.value=n;elsetext===this.el.tagName||tspan===this.el.tagName?this.el.textContent=n:this.el.innerHTML=n}},i.prototype.ensureNumber=function(t){returnnumber==typeof t&&!isNaN(t)},i.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error=[CountUp] invalid start or end value: .concat(t),null)},i.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3Number(this.options.duration),this.remaining=this.duration},i}();export{i as CountUp}; 3:06:59 PM: SyntaxError: Unexpected token 'export' 3:06:59 PM: at Object.compileFunction (node:vm:360:18) 3:06:59 PM: at wrapSafe (node:internal/modules/cjs/loader:1126:15) 3:06:59 PM: at Module._compile (node:internal/modules/cjs/loader:1162:27) 3:06:59 PM: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10) 3:06:59 PM: at Module.load (node:internal/modules/cjs/loader:1076:32) 3:06:59 PM: at Function.Module._load (node:internal/modules/cjs/loader:911:12) 3:06:59 PM: at Module.require (node:internal/modules/cjs/loader:1100:19) 3:06:59 PM: at require (node:internal/modules/cjs/helpers:108:18) 3:06:59 PM: at Object. (/opt/build/repo/node_modules/react-countup/build/index.js:6:18) 3:06:59 PM: at Module._compile (node:internal/modules/cjs/loader:1198:14) 3:06:59 PM: > Build error occurred 3:06:59 PM: Error: Failed to collect page data for /diets 3:06:59 PM: at /opt/build/repo/node_modules/next/dist/build/utils.js:963:15 { 3:06:59 PM: type: 'Error' 3:06:59 PM: }

this is my package.json

{ "name": "ideatofit", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "export": "next build && next export" }, "dependencies": { "@emotion/react": "^11.10.6", "@emotion/styled": "^11.10.6", "@fontsource/poppins": "^4.5.10", "@fortawesome/free-solid-svg-icons": "^6.3.0", "@fortawesome/react-fontawesome": "^0.2.0", "@mui/material": "^5.11.13", "@next/font": "13.1.6", "@plaiceholder/next": "^2.5.0", "@popperjs/core": "^2.11.6", "@types/node": "18.13.0", "@types/react": "18.0.28", "@types/react-dom": "18.0.10", "bootstrap": "^5.2.3", "eslint": "8.34.0", "eslint-config-next": "13.1.6", "formik": "^2.2.9", "framer-motion": "^10.0.1", "fs": "0.0.1-security", "install": "^0.13.0", "msg91": "^2.0.4", "net": "^1.0.2", "next": "13.1.6", "next-auth": "^4.20.1", "next-seo": "^5.15.0", "next-share": "^0.19.0", "pg": "^8.10.0", "plaiceholder": "^2.5.0", "qs": "^6.11.0", "react": "18.2.0", "react-bootstrap": "^2.7.2", "react-countup": "^6.4.2", "react-dom": "18.2.0", "react-icons": "^4.8.0", "react-intersection-observer": "^9.4.3", "react-phone-input-2": "^2.15.1", "react-select-country-list": "^2.2.3", "react-visibility-sensor": "^5.1.1", "react-waypoint": "^10.3.0", "strapi-sdk-javascript": "^0.3.3", "tsl": "^0.1.0", "twilio": "^4.10.0", "typescript": "4.9.5", "yup": "^1.0.2" }, "devDependencies": { "@types/qs": "^6.9.7", "@types/react-select-country-list": "^2.2.1", "@zeit/next-css": "^1.0.1", "autoprefixer": "^10.4.13", "i": "^0.3.7", "npm": "^9.6.2", "postcss": "^8.4.21", "prettier": "2.8.4", "sharp": "^0.32.0", "tailwindcss": "^3.2.7" } }

mmarkelov commented 1 year ago

close as a duplicate of https://github.com/glennreyes/react-countup/issues/805