作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 npm 包 https://www.npmjs.com/package/swipe-detect并收到以下错误消息
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)
npm WARN deprecated @babel/polyfill@7.4.4: 🚨 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";
最佳答案
根据您的 Electron/Node 版本,使用 --experimental-modules
争论可能足以让它发挥作用。 (但是可能有 issues when you try to package your app 。)
见 https://github.com/electron/electron/issues/12011了解在 Electron 中使用 ES 模块的一些背景知识。该线程中似乎提出了各种解决方法。
(假设您想要的库是 only 100 lines ,并且在良好的自由 MIT 许可证下,克隆它可能更容易,在该文件的末尾删除默认值,然后简单地导出类。)
关于javascript - 为什么在 Electron 中安装 Babel 失败?我是否需要通天塔?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57196869/
我是一名优秀的程序员,十分优秀!