Having trouble using the npm package https://www.npmjs.com/package/swipe-detect and encountering the following error message:
export default function(target, callback, threshold=150) {
^^^^^^
SyntaxError: Unexpected token export
at Module._compile (internal/modules/cjs/loader.js:776:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:851:10)
at Module.load (internal/modules/cjs/loader.js:701:32)
at tryModuleLoad (internal/modules/cjs/loader.js:633:12)
at Function.Module._load (internal/modules/cjs/loader.js:625:3)
at Module.require (internal/modules/cjs/loader.js:739:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (C:\Users\folder\main.js:22:22)
at Module._compile (internal/modules/cjs/loader.js:839:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:851:10)
It seems to be an issue with ES6 syntax, so I've tried to install babel following this tutorial: . But encountered an error message:
npm WARN deprecated @babel/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0676696a7f606f6a6a463128322832">[email protected]</a>: 🚨 As of Babel 7.4.0, this
npm WARN deprecated package has been deprecated in favor of directly
npm WARN deprecated including core-js/stable (to polyfill ECMAScript
npm WARN deprecated features) and regenerator-runtime/runtime
npm WARN deprecated (needed to use transpiled generator functions):
npm WARN deprecated
npm WARN deprecated > import "core-js/stable";
npm WARN deprecated > import "regenerator-runtime/runtime";
Despite trying different tutorials and setting up the environment in .babelrc, I still get the error message.
After some research, I found out that babel is already integrated in Electron. Check out this discussion: Why is Babel needed in an Electron project.
I've been struggling for two days now, unable to find a solution. Can anyone help me understand why this error keeps appearing?