I'm getting error Module not found: Error: Can't resolve './dbctrl' in '/Users/me/Documents/todo/todo-frontend/src'.
My code is ...
todo.ts import DbControl from "./dbctrl"; // import { getToDo, writeToDo } from "./dbctrl"; // import * as dbctrl from "./dbctrl";
-> I have tried comments too.
dbctrl.ts
import axios from "axios";
const URL = "http://localhost:4000";
export default class DbControl {
public getToDo = () => {
axios.get(URL + "/api/todos").then(response => {
console.log(response.data);
});
};
public writeToDo = (title: string, toggle: boolean) => {
axios.post(URL + "/api/todos", { title, toggle }).then(response => {
console.log(response.data);
});
};
}
webpack.config.js
const path = require("path");
module.exports = {
target: "web",
entry: ["./src/todo.ts", "./src/style.css"],
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
}
]
},
resolve: {
extensions: [".js", ".jsx", ".css", "tsx", "ts", "json"]
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "./dist")
// sourceMapFilename: "[name].[hash:8].map"
// chunkFilename: "[id].[hash:8].js"
},
mode: "development",
devServer: {
port: 4010
}
};
I don't know what is wrong. Please let me know ... Thank you
Aucun commentaire:
Enregistrer un commentaire