我得到的错误Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.,当我运行命令npm run dev我也收到这下一个一个错误,指出ERROR in Entry module not found: Error: Can't resolve后跟路径。我不太确定为什么它找不到入口点任何帮助将不胜感激。
将整个项目上传到 github 以帮助提高可见性。 https://github.com/dustinm94/coding-challenge
webpack.config.js
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
包.json
{
"name": "coding_challenge",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development --watch ./coding/frontend/src/index.js --output ./coding/frontend/static/frontend/main.js",
"build": "webpack --mode production ./coding/frontend/src/index.js --output ./coding/frontend/static/frontend/main.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
},
"dependencies": {
"babel-preset-react": "^6.24.1",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
}
Run Code Online (Sandbox Code Playgroud)
.babelrc
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["transform-class-properties"]
}
Run Code Online (Sandbox Code Playgroud)
div*_*ine 12
webpack.config.js并且package.json将始终在您的项目基本路径中,节点命令应从此路径触发
您必须在webpack.config.js& 中进行以下更正package.json
--watch将自动查找entryobject in 中指定的文件,webpack.config.js并继续观察其依赖关系图以在检测到更改时自动重新加载。您需要package.json使用以下详细信息更新您的
"scripts": {
"webpack" : "webpack", // invoke this command from npm run dev & npm run build
"dev": "npm run webpack -- --mode development --watch",
"build": "npm run webpack -- --mode production"
}
Run Code Online (Sandbox Code Playgroud)
在监视模式下运行可能会导致性能问题,具体取决于您使用的硬件,阅读更多相关信息
将entry对象添加到您的webpack.config.js. 如果你没有覆盖 entry 对象,默认情况下,webpack 将entry对象指向 './src/index.js`。由于您没有在项目中使用默认配置,webpack 会抛出错误
ERROR in Entry module not found: Error: Can't resolve './src' in '/root/../coding_challenge'
Run Code Online (Sandbox Code Playgroud)
要修复错误,您需要entry使用目标js文件覆盖对象,如下所示
module.exports = {
entry : "./frontend/src/index.js",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
如果完成上述更正,
npm run dev 将以监视模式运行您的项目
npm run build 将为您的项目生成生产版本
如果此信息能解决您的问题,请告诉我
| 归档时间: |
|
| 查看次数: |
26931 次 |
| 最近记录: |