【发布时间】:2020-12-14 17:27:29
【问题描述】:
我今天刚开始学习 React。 如何在 Visual Studio 的终端中的控制台上消除该错误消息。
(node: 9374)Warning: To load an ES module,
set "type": "module" in the package.json or use the .mjs extension.
/Users/nishihaider/workspace-ui/react-todo-app/src/App.js:1
import React from "react";
import "./App.css";
function App() {
<>
return (
<h1>ToDo</h1>
);
</>
}
export default App;
【问题讨论】:
-
在 monorepo(Angular + Express + 单个 package.json)中使用 ts-node 时遇到了同样的问题。显式指定 tsconfig.json 的路径修复了问题:
--project express-server/tsconfig.json。 github.com/TypeStrong/ts-node#loading-tsconfigjson
标签: javascript reactjs es6-modules