JavaScript模块没有加载
我正在尝试将一个模块导入我的JavaScript代码,该模块稍后应在WordPress服务器上运行。 目前,我想在Localhost上进行测试,但它给了我一个错误: “ http://127.0.0.1:46513/js/main.js”的SKRIPT已加载,尽管它是Mime-Typ(“ Text/html”)在Javascript
中无效 这很奇怪,因为它是JS代码,而不是HTML。 我的主要.js看起来像这样:
const {origan,星座} = require('./ coundular-natal-horoscope-js/dist/dist/index.js');
and code> and index.html像这样:
<html>
<head> Horoscope </head>
<body>
<script type="text/javascript" src="js/require.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
我还尝试了不同的导入语法: import {Origin,星座}来自'/circular-natal-horoscope-js/dist/index.js';
这给了我同样的错误。
唯一有效的是,当我将node main.js
输入控制台时,origin和星座函数正在加载。
我如何在不使用控制台的情况下使用它在JS文件中工作?
I am trying to import a module to my JavaScript code, which should later run on a WordPress server.
Currently i wanted to test it on localhost, but it gives me an error like:The Skript from "http://127.0.0.1:46513/js/main.js" was loaded, despite it's MIME-Typ ("text/html") is not valid in JavaScript
Which is strange because it is js code and not html.
My main.js looks like this:
const { Origin, Horoscope } = require('./circular-natal-horoscope-js/dist/index.js');
And index.html like this:
<html>
<head> Horoscope </head>
<body>
<script type="text/javascript" src="js/require.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
I also tried different import syntax:import { Origin, Horoscope } from '/circular-natal-horoscope-js/dist/index.js';
Which gives me the same error.
The only thing which is working is, when i type in node main.js
into console, then the Origin and Horoscope functions are beeing loaded.
How can i use this to be working in my js-files without using the console?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论