I'm currently delving into the world of using TypeScript with React and am following a helpful tutorial at: https://blog.logrocket.com/how-why-a-guide-to-using-typescript-with-react-fffb76c61614
However, when attempting to run the webpack command through the npm script "pile" defined in my package.json
, I encounter the error message:
ERROR in Entry module not found: Error: Can't resolve './src' in '/my/home/directory/projects/tsx-tutorial'
Below is the directory structure of my project:
tsx-tutorial
├── app.tsx {<---- Is this supposed to be my entry point?}
├── dist
├── index.html
├── index.ts
├── lookTree.txt
├── node_modules.zip
├── package-lock.json
├── package.json
├── src {<----- Ah, there it is??}
│ └── hello.ts
├── tsconfig.json
└── webpack.config.js
2 directories, 10 files
Here's my webpack.config.js
:
var path = require("path");
var config = {
entry: "app.tsx", // Why isn't there anything referring to ./src here?
output: {
path: path.resolve(__dirname, "build"),
filename: "bundle.js"
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
module: {
loaders: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/
}
]
}
};
I've made sure to not request any files from 'src', so why is it looking there? It feels like I'm overlooking something quite fundamental.
Lastly, here's my package.json
:
{
"name": "tsx-tutorial",
"version": "0.0.1",
"description": "to help me learn tsx-fu",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"pile": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^4.4.1",
"webpack": "^4.12.1",
"webpack-cli": "^3.0.8"
},
"dependencies": {
"@types/react": "^16.4.1",
"@types/react-dom": "^16.0.6",
"react": "^16.4.1",
"react-dom": "^16.4.1"
}
}
Your assistance in helping me navigate through these issues is greatly appreciated! Thank you for guiding a beginner like myself.