javascript - 错误 "File is a commonJS module; it may be converted to an ES6 module. ts(80001)"

标签 javascript visual-studio-code vscode-settings commonjs

在vscode中开发javascript,在const Koa = require("Koa");线上看到这个错误:

File is a CommonJS module; it may be converted to an ES6 module. ts(80001)



在我搜索后发现只有 1 个解决方案可以禁用所有建议操作。

如何在不禁用所有建议操作的情况下仅禁用“要求”错误?

最佳答案

它暗示将代码转换为支持 ES 模块标准。 ES 模块是浏览器和后端节点环境都支持的标准模块格式。

关于javascript - 错误 "File is a commonJS module; it may be converted to an ES6 module. ts(80001)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56627958/

相关文章:

javascript - RegEx 作为 if else 语句中的条件返回意外结果

typescript - 如何设置 typescript 编译器 (tsc) 的默认目标 es 版本?

git - 如何在 Visual Studio Code 中查看 Git 历史记录?

visual-studio-code - 有没有办法在 vs code explorer 中展平或合并单个文件夹?

visual-studio-code - 在 VSCode 终端中将 WSL 设置为 CWD

javascript - 获取 JSON 并处理 JSON 中的各个信息

javascript - 按单词进行过滤而不隐藏它们

python - 如何在ubuntu上的vs code中编写python?

visual-studio-code - 如何在 VS Code 中更 retrofit 订线宽度?

javascript - 使用 React 为同一对象的多个实例动态创建网页