我目前正在尝试在我的后端中实现打字稿,但是由于它是我的新手,所以我试图在测试文件夹中逐一找出问题,但是似乎webpack正在占用我的所有文件并尝试阅读它们,这给了我类似以下错误:
Duplicate identifier
,Module '"xxxx"' has no default export
,Cannot find name 'Proxy'.
,Cannot redeclare block-scoped variable 'xxxx'.
这是我的配置文件(出于某种原因仍使用webpack3):
"use strict"
const path = require("path")
// const utils = require("./utils")
// const config = require("../config")
var fs = require("fs")
const NodemonPlugin = require("nodemon-webpack-plugin")
const nodeExternals = require("webpack-node-externals")
function resolve(dir)
{
return path.join(__dirname, "..", dir)
}
module.exports = {
context: path.resolve(__dirname, "../src/server/test"),
entry: "./test.ts",
output: {
path: path.resolve(__dirname, "../src/server/test"),
filename: "bundle.js",
},
plugins: [
// new NodemonPlugin(),
],
resolve: {
extensions: [".js",".ts", ".tsx"],
alias: {
"@": resolve("src"),
"#": resolve("src/server")
}
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
include: [resolve("src"), resolve("test")]
},
{
test: /\.tsx?$/,
loader: "ts-loader",
},
]
},
externals: [
nodeExternals()
],
target: "node"
}