npm run build报错 ,resolve is not defined

今天在build项目的时候报: 

ReferenceError: resolve is not defined

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: cross-env NODE_ENV=production webpack --progress --hide-modules
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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:UsersyingyiAppDataRoamingnpm-cache_logs2018-05-21T11_19_19_460Z-debug.log

查了一些文档发现是缺少辅助函数,在webpack的配置文件中加上就好了

function resolve (dir) {
return path.join(__dirname, '..', dir)
}

使用vue-cli+webpack搭建的项目一般都有这个,如果是自己单引入的配置文件可能会报这个错,推荐使用脚手架工具搭建环境。

猜你喜欢

转载自www.cnblogs.com/leeke98/p/10759995.html