Webpack v5配置报错:fallback参数不符合Schema问题求助
Webpack v5.82.1中配置resolve.fallback提示参数不存在的问题排查
我在Webpack v5.82.1环境下配置webpack.partial.js时遇到异常:按照官方文档添加resolve.fallback参数后,执行启动命令:
"start": "webpack -v && ng serve --extra-webpack-config webpack.partial.js -o"
出现如下报错:
An unhandled exception occurred: Invalid configuration object. Webpack has been initialised using
a configuration object that does not match the API schema.
- configuration.resolve has an unknown property 'fallback'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, concord?, descriptionFiles?,
enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?,
moduleExtensions?, modules?, plugins?, resolver?, roots?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
错误堆栈详情:
at Object.webpack [as webpackFactory] (C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\webpack.js:31:9) at createWebpack (C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:21:36) at Object.runWebpackDevServer (C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:47:12) at SwitchMapSubscriber.project (C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:167:32) at SwitchMapSubscriber._next (C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\switchMap.js:47:27) at SwitchMapSubscriber.Subscriber.next (C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\Subscriber.js:66:18) at C:\Users\i\Desktop\_REPOS\gk-datasync-frontend\serverless-site\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\util\subscribeToPromise.js:7:24) at processTicksAndRejections (node:internal/process/task_queues:96:5)
我的webpack.partial.js配置内容如下:
const webpack = require('webpack'); console.log(`partial webpack version loaded:`,webpack.version) module.exports = { resolve: { //modules: [...], fallback: { "fs": false, "tls": false, "net": false, "path": false, "zlib": false, "http": false, "https": false, "stream": false, "crypto": false, "mssql": false, "assert": false, "nodemailer": false, "xlsx": false, "original-fs": false, "url-composer": false, //if get error TS2307: Cannot find module --add here //"crypto-browserify": require.resolve('crypto-browserify'), //if you want to use this module also don't forget npm i crypto-browserify "adm-zip": false, "assert": false, "os": false, "axios-ntlm": false, "http": false, "https": false, "stream-http": false, "https-browserify": false } }, plugins: [ new webpack.DefinePlugin({ "VERSION": JSON.stringify("4711") }) ] }
日志显示加载的Webpack版本为5.82.1,但报错却提示fallback参数不存在,求排查问题原因。
内容的提问来源于stack exchange,提问作者Rilcon42
相关产品推荐
相关产品推荐

