最近在学习webpack
,刚开始就遇到了问题,以下是我的文件目录
webpack-config.js:
var webpack = require('webpack');
var path = require('path');
var buildPath = path.resolve(__dirname,"build");
var nodemodulesPath = path.resolve(__dirname,'node_modules');
var config = {
//入口文件配置
entry:path.resolve(__dirname,'src/main.js'),
resolve:{
extentions:["","js"]//当requrie的模块找不到时,添加这些后缀
},
//文件导出的配置
output:{
path:buildPath,
filename:"app.js"
}
}
module.exports = config;
main.js:
var a = require('./js/a');
a();
console.log('hello world');
document.getElementById("container").innerHTML = "<p>hello world</p>";
但当我在命令行里执行下面语句时却报了这样的错误:
在网上我也找了一些资料,但还是没有用,webpack我是全局安装的npm install webapck -g
请教大神能帮忙解决下,谢谢!
在项目根目录安装webpack