我一直遇到节点 js 的问题。
这是相关代码(app.ts):
const express = require("express");
const auth = require("./service/auth");
import { Request, Response } from "express";
import User from "./model/User";
import con from "./config/db";
const port = 3000;
const app = express();
app.use(express.json());
...
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
(node:16524) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
C:\Users\010bo\OneDrive\Documents\GitHub\rpg-backend\app\app.ts:4
import { Request, Response } from "express";
^^^^^^
SyntaxError: Cannot …Run Code Online (Sandbox Code Playgroud)