无法解析 Electron v.17 应用程序中的 Polymer 3 模块
我得到 electron-quick-start 和 电子聚合物 来自 Fluidnext,用于我的 Polymer 3 应用程序。
当我尝试将 Web 组件导入到项目中时,出现以下错误:Uncaught TypeError: 无法解析模块说明符“@polymer/polymer/polymer-element.js”。相对引用必须以“/”、“./”或“../”开头。
为了解决这个问题,我使用了../node_modules/my-folder/my-component.js 但这仅在我导入仅引用其默认文件夹的组件时才有效。
Example:
import {
html,
PolymerElement
} from '../node_modules/@polymer/polymer/polymer-element.js';
这对我有用,这个组件显示在我的电子应用程序中,但是我有很多其他组件使用其他引用,如下所示。
import {
html,
PolymerElement
} from '../node_modules/@polymer/polymer/polymer-element.js';
// import { sharedStyles } from './shared-styles.js';
import '../node_modules/@polymer/paper-input/paper-input.js';
import '../node_modules/@polymer/iron-icon/iron-icon.js';
import '../node_modules/@polymer/iron-icons/iron-icons.js';
当我导入此组件时,我收到此错误,类似于第一个:Uncaught TypeError:无法解析模块说明符“@polymer/polymer/polymer-legacy.js”。相对引用必须以“/”、“./”或“../”开头。
这就是我现在的问题,我需要添加../node_modules
的每个新组件> 在默认聚合物导入之前以及当该组件内部有其他导入时,我在引用中遇到了其他错误。
我该如何解决这个问题?
I get electron-quick-start and electron-polymer from fluidnext to use for my Polymer 3 application.
When i try to import my webcomponents to the project, i have got this error: Uncaught TypeError: Failed to resolve module specifier "@polymer/polymer/polymer-element.js". Relative references must start with either "/", "./", or "../".
to solve this i used ../node_modules/my-folder/my-component.js
but this only worked when i import a component who has only references to his default folder.
Example:
import {
html,
PolymerElement
} from '../node_modules/@polymer/polymer/polymer-element.js';
This have worked for me, this component shows in my Electron Application, but i have a lot of others components who use other references, like this below.
import {
html,
PolymerElement
} from '../node_modules/@polymer/polymer/polymer-element.js';
// import { sharedStyles } from './shared-styles.js';
import '../node_modules/@polymer/paper-input/paper-input.js';
import '../node_modules/@polymer/iron-icon/iron-icon.js';
import '../node_modules/@polymer/iron-icons/iron-icons.js';
When i import this component i got this error, similar to the first: Uncaught TypeError: Failed to resolve module specifier "@polymer/polymer/polymer-legacy.js". Relative references must start with either "/", "./", or "../".
And that is my problem now, every new component i need to add ../node_modules
before the default polymer import and when this component has others imports inside i got other errors to the references.
How can i solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了这个问题。我有一个 Flask 应用程序,我想在我的模板中嵌入 Web 组件。我通过以下方式解决了它。我编写了以下 python 文件并在启动文件中调用它。现在一切正常了。
I also ran into this problem. I have a Flask application where I wanted to embed web components in my templates. I solved it in the following way. I have written the following python file and am calling it in the startup file. Now everything works.