gpt4 book ai didi

Webpack 4 : ERROR in Entry module not found: Error: Can't resolve './src'

转载 作者:行者123 更新时间:2023-12-01 04:35:33 24 4
gpt4 key购买 nike

这是一个重复的问题,但我想使用自定义条目而不是默认为 webpack 4 条目,正如帖子 Webpack 4: Error in entry 中所建议的那样。

webpack.dev.config.js:

import path from 'path';

export default {
mode: 'development',
entry: [
'babel-polyfill',
'./app/components/index.js'
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }
]
}
};

Project Structure

运行 时显示以下错误webpack-wd

Insufficient number of arguments or no entry found. Alternatively, run 'webpack(-cli) --help' for usage info.

ERROR in Entry module not found: Error: Can't resolve './src' in 'C:\Patient_Check_In'

最佳答案

使用commonJS webpack 配置的模块语法:

webpack.config.js

const path = require('path');

module.exports = {
mode: 'development',
entry: [
'babel-polyfill',
'./app/components/index.js'
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
}
}

包.json

{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"build": "webpack"
},
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"babel-polyfill": "^6.26.0"
}
}

应用程序/组件/index.js

console.log('hello!');

如果你运行 webpack在 dist 文件夹中生成一个名为 bundle.js 的文件,该文件包含所有 babel pollyfills,加上 webpack 运行时,加上你的应用程序(在本例中是一个简单的 console.log 语句)。如果你愿意,你可以设置一个特定的 babel 配置。

关于Webpack 4 : ERROR in Entry module not found: Error: Can't resolve './src' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51810615/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com