在VS Code中创建React Native应用时遇警告与漏洞问题
Expo项目创建时的npm警告与漏洞处理
问题现象
执行npx create-expo-app Aqua创建React Native应用时,出现多个npm废弃插件警告,且检测到5个中等严重程度的漏洞,重新创建项目后问题依旧。
命令行输出
PS D:\Coding Projects\Drinking Water Reminder App> npx create-expo-app Aqua √ Downloaded and extracted project files. npm install npm WARN deprecated @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead. npm WARN deprecated @babel/plugin-proposal-numeric-separator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead. npm WARN deprecated @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead. npm WARN deprecated @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead. npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs npm WARN deprecated @babel/plugin-proposal-optional-catch-binding@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead. npm WARN deprecated @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead. npm WARN deprecated @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead. added 1159 packages, and audited 1160 packages in 4m 65 packages are looking for funding run `npm fund` for details 5 moderate severity vulnerabilities To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details. ✅ Your project is ready! To run your project, navigate to the directory and run one of the following npm commands. - cd Aqua - npm run android - npm run ios # you need to use macOS to build the iOS project - use the Expo app if you need to do iOS development without a Mac - npm run web
处理建议
废弃插件警告
这些警告来自Babel的提案类插件,对应的语法已经被纳入ECMAScript标准,官方不再维护提案插件,转而推荐使用对应的transform插件。这类警告是Expo模板依赖的间接问题,不影响项目运行,无需手动修改依赖,等待Expo更新模板版本后会自动修复。
中等严重漏洞
- 先执行
npm audit查看漏洞的具体详情,确认是直接依赖还是间接依赖导致的问题。 - 不要轻易执行
npm audit fix --force,强制修复可能会破坏Expo项目的依赖兼容性,导致项目无法正常运行。 - 若想尝试临时解决:
- 删除项目根目录下的
node_modules文件夹和package-lock.json文件 - 重新执行
npm install,清理缓存后重新安装依赖
- 删除项目根目录下的
- 也可以尝试使用
yarn替代npm安装依赖,不同的包管理器可能会解析出更安全的依赖版本链。
内容的提问来源于stack exchange,提问作者Harsh Divine Author
相关产品推荐
相关产品推荐

