目录
问题
使用webpack命令打包的时候报错,运行命令:
webpack ./
报错:
validateSchema is not a function
解决
方法一、安装webpack
npm install webpack -g
可以使用如下命令,查看是否安装成功。
webpack -v
方法二、指定webpack版本
1. 卸载之前的版本,命令:
npm uninstall webpack
运行结果:
npm WARN [email protected] requires a peer of webpack@>=2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
audited 1253 packages in 9.442s
28 packages are looking for funding
run `npm fund` for details
found 318 vulnerabilities (301 low, 7 moderate, 10 high)
run `npm audit fix` to fix them, or `npm audit` for details
2. 安装指定版本,命令:
npm install [email protected] -g
执行结果:
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
/usr/local/bin/webpack -> /usr/local/lib/node_modules/webpack/bin/webpack.js
> [email protected] postinstall /usr/local/lib/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"<8.10.0"} (current: {"node":"8.11.3","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"^8.16.0 || ^10.6.0 || >=11.0.0"} (current: {"node":"8.11.3","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]
+ [email protected]
added 112 packages from 124 contributors, removed 93 packages, updated 24 packages and moved 4 packages in 46.777s
如果有疑问,欢迎评论留言或者私信沟通!