~/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
這個命令會嘗試自動更新有漏洞的依賴包到安全版本,不會破壞現有功能。
然后正常運行之后的代碼。