当我尝试运行时收到此错误-在命令提示符下运行npm run dev:
Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.
Hash: af4cfdb00272137cb4d3
Version: webpack 4.41.5
Time: 60ms
Built at: 02/05/2020 10:38:54 AM
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in Entry module not found: Error: Can't resolve './src' in 'C:\Users\dahiy\Desktop\Web developer Course\JS - Basics 2\forkit'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! forkify@1.0.0 dev: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the forkify@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
这是我的webpack.config.js的样子:
const path = require('path');
module.exports = {
entry:'./src/js/index.js',
output: {
path: path.resolve(__dirname, 'dist/js'),
filename:'bundle.js'
},
mode:'development'
};
这是我的package.json:
{
"name": "forkify",
"version": "1.0.0",
"description": "forkify project",
"main": "index.js",
"scripts": {
"dev": "webpack"
},
"author": "Sachin Dahiya",
"license": "ISC",
"devDependencies": {
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"dependencies": {}
}
我已尽一切努力解决此错误,但未获得任何解决方案。请帮帮我。在此处附加错误的屏幕截图。 error
答案 0 :(得分:0)
// webpack.config.js
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, 'src/js/index.js'),
output: {
path: path.resolve(__dirname, 'dist/js'),
filename:'bundle.js'
},
mode:'development'
};
由于您使用的是Windows,因此看起来前/后斜线混淆是一个问题
答案 1 :(得分:0)
检查CAPS的文件名。 在本地计算机上运行并没有给出错误,但是当我在Linux上运行时,却出现了与上述类似的错误。
我发现了文件名问题。在导入时,我有
从“ ./login”导入登录名;
但是文件名是Login.js 当我将登录名更改为登录名时,它对我有用 从“ ./登录”导入登录名;