【发布时间】:2017-05-28 06:58:28
【问题描述】:
我在尝试通过 webpack 2 构建我的应用程序时收到错误消息。
我的应用文件夹结构如下:
/
| - dist/
|
| - src/
| |
| | - modules/
| | |
| | | - module1.js
| |
| | - index.js *
|
| _ webpack.config.js
|
| - package.json
我的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'
},
....
}
当我运行 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
现在,我正在慢慢学习 webpack,这很可能是对 webpack 的 context 属性如何工作的简单误解。 PATHS.src 等于我的项目的src 目录的绝对路径,我的入口点是./index.js,它在那个目录里面。谁能帮我确定我收到此错误的原因?
谢谢!
【问题讨论】:
标签: javascript node.js webpack webpack-2