npm WARN EBADENGINE required: { node: ‘>=14‘ }

bash 复制代码
syh@syh-HKF-WXX:~$ npm install @lark-opdev/cli@latest -g
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'hpagent@1.2.0',
npm WARN EBADENGINE   required: { node: '>=14' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'typescript@5.8.2',
npm WARN EBADENGINE   required: { node: '>=14.17' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/syh/.npm/_logs/2025-03-16T07_25_18_634Z-debug-0.log

主要包含两个问题:


1. Node.js 版本过低

错误:

复制代码
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'hpagent@1.2.0',
npm WARN EBADENGINE   required: { node: '>=14' },
npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }

你的当前 Node.js 版本是 v12.22.9 ,但是 @lark-opdev/cli 依赖的 hpagenttypescript 需要 Node.js >= 14,因此你的 Node.js 版本太旧了,需要升级。

解决方案

运行以下命令升级 Node.js:

sh 复制代码
sudo apt update
sudo apt install -y nodejs npm

如果安装后版本还是较低,可以使用 Node Version Manager (NVM) 进行升级:

sh 复制代码
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
source ~/.bashrc
nvm install 18
nvm use 18

然后检查 Node.js 版本:

sh 复制代码
node -v

确保 Node.js 版本 >=14


2. 权限不足

错误:

复制代码
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'

你尝试全局安装 (-g) 依赖时,npm 需要写入 /usr/local/lib/node_modules,但你没有足够的权限。

解决方案

方法 1:使用 sudo

sh 复制代码
sudo npm install @lark-opdev/cli@latest -g

如果不想一直用 sudo,可以修正 npm 的权限:

sh 复制代码
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

方法 2:使用 --prefixnpm 安装到用户目录

sh 复制代码
npm install --prefix ~/.npm-global @lark-opdev/cli@latest -g

然后添加 ~/.npm-global/binPATH

sh 复制代码
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

最终步骤

  1. 升级 Node.js (至少 14+,推荐 18+)

  2. 使用 sudo 或修正权限

  3. 重试安装

    sh 复制代码
    npm install @lark-opdev/cli@latest -g
相关推荐
该用户已不存在几秒前
AI编程工具大盘点,哪个最适合你
前端·人工智能·后端
一头小鹿14 分钟前
【React Native+Appwrite】获取数据时的分页机制
前端·react native
冴羽22 分钟前
这是一个很酷的金属球,点击它会产生涟漪……
前端·javascript·three.js
烛阴29 分钟前
为什么 `Promise.then` 总比 `setTimeout(..., 0)` 快?微任务的秘密
前端·javascript·typescript
XiaoSong34 分钟前
基于 React Native/Expo 项目的持续集成(CI)最佳实践配置指南
前端·react native·react.js
white-persist40 分钟前
汇编代码详细解释:汇编语言如何转化为对应的C语言,怎么转化为对应的C代码?
java·c语言·前端·网络·汇编·安全·网络安全
张愚歌1 小时前
轻松打造个性化Leaflet地图标记
前端·javascript
华仔啊1 小时前
CSS实现高级流光按钮动画,这几行代码堪称神来之笔
前端·css
歪歪1001 小时前
详细介绍一下“集中同步+分布式入库”方案的具体实现步骤
开发语言·前端·分布式·后端·信息可视化
林太白1 小时前
rust17-部门管理模块
前端·后端·rust