npm run build報錯 ,resolve is not defined


今天在build項目的時候報: 

ReferenceError: resolve is not defined

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yingyi@1.0.0 build: cross-env NODE_ENV=production webpack --progress --hide-modules
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yingyi@1.0.0 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搭建的項目一般都有這個,如果是自己單引入的配置文件可能會報這個錯,推薦使用腳手架工具搭建環境。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM