Expo 49.0.11网页编译失败:Webpack Dev Server废弃警告求助
我创建了一个未做任何修改的全新Expo项目,但启动时遇到以下弃用警告:
(node:1331) [DEP_WEBPACK_DEV_SERVER_CONSTRUCTOR] DeprecationWarning: Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument.(Use
node --trace-deprecation ...to show where the warning was created)(node:1331) [DEP_WEBPACK_DEV_SERVER_LISTEN] DeprecationWarning: 'listen' is deprecated. Please use the async 'start' or 'startCallback' method.
怀疑是Expo SDK 49新版本的问题,请问该如何解决?
已附上package.json和app.json文件截图。
升级Expo相关依赖到最新补丁版本:SDK 49刚发布时可能存在webpack-dev-server适配问题,运行以下命令自动更新依赖:
npx expo upgrade该操作会同步升级Expo及关联依赖到SDK 49的最新兼容版本,通常能修复这类兼容性警告。
手动锁定webpack-dev-server兼容版本:如果升级后问题仍存在,可在
package.json中指定适配的webpack-dev-server版本(如^4.15.1):- 在
package.json的devDependencies中添加:"webpack-dev-server": "^4.15.1" - 执行
npm install或yarn install重新安装依赖。
- 在
临时忽略警告:如果警告不影响项目正常运行,可在启动命令中添加参数屏蔽弃用警告:
NODE_NO_WARNINGS=1 npx expo start也可以修改
package.json的启动脚本:"scripts": { "start": "NODE_NO_WARNINGS=1 expo start" }
内容的提问来源于stack exchange,提问作者Michael Menegoi

