Node.js UnhandledPromiseRejectionWarning on foreach loop

mikkuslice Source

I have a simple piece of code which runs a foreach loop. The code is as follows:

    Array.from(scrollItems).forEach((item) => {
            var offTop = $(item).offset().top;
            if(offTop < fromTop){
                cur = item;

Whenever I run

     npm run build [-- --env=prod]

I get the following error message:

      94% asset optimization(node:12284) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token: operator (>) (node:12284) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I was able to pinpoint the code block mentioned above because whenever I comment it out the build is always successful. Also, I noticed that the issue does not occur whenever I run serve, so during development this never happened either.



comments powered by Disqus