简体   繁体   English

Webpack 2无法解析webpack.config.js中的入口点

[英]Webpack 2 not resolving entry point in webpack.config.js

I'm receiving an error when attempting to build my application via webpack 2. 尝试通过webpack 2构建应用程序时收到错误消息。

My app folder structure looks like this: 我的应用程序文件夹结构如下所示:

/
| - dist/
|
| - src/
|   |  
|   | - modules/
|   |   |
|   |   | - module1.js
|   |
|   | - index.js *
|
| _ webpack.config.js
|
| - package.json

The relevant portion of my webpack.config.js file is here: 我的webpack.config.js文件的相关部分在这里:

/**
 * Requires
 */
const path = require('path');


/**
 * Variables
 */
const PATHS = {
  src: path.join(__dirname, 'src'),
  dist: path.join(__dirname, 'dist')
};


/**
 * Configuration
 */
module.exports = {

  entry: {
    context: PATHS.src,
    main: './index.js'
  },

  ....
}

When I run npm run build , which is my script alias for webpack --display-error-details , I receive the following error details: 当我运行npm run build ,这是我的webpack --display-error-details脚本别名,我收到以下错误详细信息:

ERROR in Entry module not found: Error: Can't resolve './index.js' in <my project path>
resolve './index.js' in <my project path>
  using description file: <my project path>/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration

Now, I'm slowly learning webpack and this could very well be a simple misunderstanding of how webpack's context property works. 现在,我正在慢慢学习webpack,这很可能是对webpack的context属性如何工作的简单误解。 PATHS.src equals the absolute path of my project's src directory, and my entry point is ./index.js , which is inside of that directory. PATHS.src等于项目的src目录的绝对路径,我的入口是./index.js ,它位于该目录内。 Can anybody help me identify why I'm receiving this error? 谁能帮助我确定为什么我收到此错误?

Thanks! 谢谢!

您是否尝试使用'./src/index.js'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM