简体   繁体   English

难以解决 Javascript 中的导入错误

[英]Difficulty resolving errors with imports in Javascript

I am new to JavaScript and vscode and getting it set up has been more difficult than any other language I have used at work.我是 JavaScript 和 vscode 的新手,设置它比我在工作中使用的任何其他语言都要困难。 When I run the code (in Test.js):当我运行代码时(在 Test.js 中):

    var msg = 'here';
    console.log(msg);
    import { Machine, interpret } from 'xstate';

I get a error saying that I must use import to load ES module.我收到一条错误消息,说我必须使用 import 来加载 ES 模块。 I have looked at similar StackExchange threads to no avail despite attempting those fixes.尽管尝试了这些修复,我还是查看了类似的 StackExchange 线程,但无济于事。 Any help and readable resources are appreciated.感谢任何帮助和可读资源。 Thanks.谢谢。

Specific error debug printout:具体错误调试打印输出:

Waiting for the debugger Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: 

import行放在顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM