首页 > 技术文章 > webpack5对node环境的要求

sk-3 2021-06-29 11:19 原文

最近项目组里来了个新人,电脑node版本10.2...前端项目采用webpack5构建,启动前端项目时,一直存在报错

错误详情:

ERROR in   Error: require(...).pathToFileURL is not a function
  
  - index.html:93 
    /Users/zhou/Desktop/app/public/index.html:93:51
  
  - index.html:112 
    /Users/zhou/Desktop/app/public/index.html:112:13
  
  - index.html:123 
    /Users/zhou/Desktop/app/public/index.html:123:12
  
  - index.js:142 HtmlWebpackPlugin.evaluateCompilationResult
    [app]/[html-webpack-plugin]/index.js:142:28
  
  - index.js:324 Promise.resolve.then
    [app]/[html-webpack-plugin]/index.js:324:26
  
  - next_tick.js:68 process._tickCallback
    internal/process/next_tick.js:68:7

html-webpack-plugin对应版本是5.x版本

当时在其他人的电脑上,其实都没有这个构建错误,感觉就是个环境问题

仔细看了下文档,现在webpack5有最低的node版本要求,因此升级对应版本就可以了

推荐阅读