我正在建立自己的小型个人项目,偶然发现打字稿出现问题并做出反应。当我使用index.js作为入口点时,一切都很好,但是当我使用.tsx文件时,出现以下错误:
EntryModuleNotFoundError: Entry module not found: Error: Can't resolve './src'
我可以只使用.js,但是我很好奇为什么会这样。详细的错误消息指定它只查找.wasm,.mjs,.js和.json文件扩展名,而忽略了我投入解析的任何内容:{扩展名:[]}。
no extension
Field 'browser' doesn't contain a valid alias configuration
[path_to_project]\src\index doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
[path_to_project]\src\index.wasm doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
[path_to_project]\src\index.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
[path_to_project]\src\index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
[path_to_project]\src\index.json doesn't exist
我的webpack.config.js文件:
const path = require('path');
module.export = {
mode: 'development',
devtool: 'cheap-module-source-map',
entry: {
app: './src/index.tsx'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'pfgen.bundle.js'
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.ts', '.d.ts', '.tsx']
}
};
这是我的项目存储库:REPOSITORY 这是我正在使用的webpack版本:
"ts-loader": "^5.3.1",
"typescript": "^3.2.2",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
答案 0 :(得分:0)
将module.export更改为module。导出。刚刚使用您的Git存储库进行了拉动,更改和成功构建,
顺便说一句,还要在您的.gitignore中添加/ node_modules,以便像VSCode这样的编辑器在与master相比时不会查看该目录。
干杯!