找不到输入模块:错误:无法解析"./src" [英] Entry module not found: Error: Can't resolve './src'

查看:357
本文介绍了找不到输入模块:错误:无法解析"./src"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照有关设置webpack和babel的反应的教程进行操作,但是我遇到了错误.

我尝试重新安装所有模块,但没有成功.我还匹配了我的配置代码,仍然没有运气.

ReactJs@1.0.0创建C:\ Users \ Gourav Thakur \ Desktop \ Me Creative \ github_codebase \ ReactJs webpack

参数数量不足或找不到条目. 或者,运行"webpack(-cli)--help"以获取使用信息.

哈希:854e6cae7eaf01829eca 版本:webpack 4.30.0 时间:82ms 建于:04/28/2019 2:01:14 PM

警告配置 尚未设置模式"选项,Webpack将为此值回退到生产"状态.将模式"选项设置为开发"或生产"以启用每个环境的默认设置. 您也可以将其设置为"none"以禁用任何默认行为.了解更多信息: https://webpack.js.org/concepts/mode/

找不到入口模块中的错误:错误:无法解析'C:\ Users \ Gourav Thakur \ Desktop \ Me Creative \ github_codebase \ ReactJs中的'./src' npm ERR!代码ELIFECYCLE npm ERR! errno 2 npm ERR! ReactJs@1.0.0创建:webpack npm ERR!退出状态2 npm ERR! npm ERR!在ReactJs@1.0.0创建脚本处失败. npm ERR! npm可能不是问题.上面可能还有其他日志记录输出.

npm ERR!可以在以下位置找到此运行的完整日志: npm ERR! C:\ Users \ Gourav Thakur \ AppData \ Roaming \ npm-cache_logs \ 2019-04-28T08_31_14_980Z-debug.log

![错误] [1]

![目录结构] [2]

![webpack.config.js] [3]

![package.json] [4]

![index.js] [5]

解决方案

webpack @ 4输入的默认值:

默认情况下,其值为./src/index.js,但是您可以通过在webpack> configuration中配置entry属性来指定其他(或>多个入口点).

要添加自定义入口点,请按照以下说明更新您的Webpack.此外,将您的webpack配置文件移至根文件夹.

entry: path.resolve(__dirname) + '/path/to/your/index.js',

但是,在新版本的webpack 4.29.*中,您不再需要webpack配置文件,因此您可以使用以下命令将其打包

webpack ./app/index.js --output ./dist/app.bundle.js --mode development

I am following a tutorial for setting up react with webpack and babel but i am getting errors.

I have tried re-installing all modules but it didn't worked. I have also matched my config codes still no luck.

ReactJs@1.0.0 create C:\Users\Gourav Thakur\Desktop\Me Creative\github_codebase\ReactJs webpack

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

Hash: 854e6cae7eaf01829eca Version: webpack 4.30.0 Time: 82ms Built at: 04/28/2019 2:01:14 PM

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/concepts/mode/

ERROR in Entry module not found: Error: Can't resolve './src' in 'C:\Users\Gourav Thakur\Desktop\Me Creative\github_codebase\ReactJs' npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! ReactJs@1.0.0 create: webpack npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the ReactJs@1.0.0 create script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Gourav Thakur\AppData\Roaming\npm-cache_logs\2019-04-28T08_31_14_980Z-debug.log

![Error][1]

![Directory structure][2]

![webpack.config.js][3]

![package.json][4]

![index.js][5]

解决方案

webpack@4 default value for entry:

By default its value is ./src/index.js, but you can specify a different (or >multiple entry points) by configuring the entry property in the webpack >configuration.

To add a custom entry point, update your webpack as mentioned below. Moreover, move your webpack config file to the root folder.

entry: path.resolve(__dirname) + '/path/to/your/index.js',

However, in the new version of webpack 4.29.* you don't need a webpack config file anymore, so you use the command below to bundle it

webpack ./app/index.js --output ./dist/app.bundle.js --mode development

这篇关于找不到输入模块:错误:无法解析"./src"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆