【已解决】npm install报错

发布于:2025-08-09 ⋅ 阅读:(14) ⋅ 点赞:(0)

~/autodl-tmp/App/magic_conch_frontend# npm install

报错内容:

WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: '@vitejs/plugin-vue@5.1.4', npm WARN EBADENGINE required: { node: '^18.0.0 || >=20.0.0' }, npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' } npm WARN EBADENGINE } npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: 'rollup@4.24.0', npm WARN EBADENGINE required: { node: '>=18.0.0', npm: '>=8.0.0' }, npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' } npm WARN EBADENGINE } npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: 'vite@5.4.8', npm WARN EBADENGINE required: { node: '^18.0.0 || >=20.0.0' }, npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' } npm WARN EBADENGINE }

根据提示更新包的版本就好

1.安装较新的 Node.js(推荐 18.x 或 20.x LTS 版本)

可以使用 nvm(Node 版本管理器)来灵活管理版本:

# 安装 nvm(如果还没安装)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# 重启终端或执行以下命令使 nvm 生效
source ~/.bashrc

# 安装 Node.js 18.x(LTS 长期支持版,兼容性好)
nvm install 18

# 切换到刚安装的版本
nvm use 18

安装后重新运行,又有了新的警告:

npm install up to date, audited 107 packages in 5s 18 packages are looking for funding run `npm fund` for details 7 vulnerabilities (2 low, 3 moderate, 1 high, 1 critical) To address issues that do not require attention, run: npm audit fix Some issues need review, and may require choosing a different dependency. Run `npm audit` for details.

7 vulnerabilities 说明项目依赖中存在 7 个安全漏洞(2 个低危、3 个中危、1 个高危、1 个严重)。

2. 快速修复可自动解决的漏洞

npm audit fix

这个命令会尝试自动更新有漏洞的依赖包到安全版本,不会破坏现有功能。

然后正常运行之后的代码。


网站公告

今日签到

点亮在社区的每一天
去签到