尝试通过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,这很可能是对webpackcontext
属性如何工作的简单误解。PATHS.src
等于项目src
目录的绝对路径,而我的入口是./index.js
,位于该目录的内部。谁能帮助我确定为什么我收到此错误?
谢谢!
你尝试过 './src/index.js'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句