You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建Expo CLI应用时遇"Error: spawn npm ENOENT"错误求解决

解决npx create-expo-app报错spawn npm ENOENT及ERR_INVALID_ARG_TYPE问题

执行npx create-expo-app创建React Native应用时出现以下错误:

Something went wrong in downloading and extracting the project files: spawn npm ENOENT
Error: spawn npm ENOENT
node:internal/validators:95
      throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
            ^

TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('ENOENT')
    at process.set [as exitCode] (node:internal/bootstrap/node:123:9)
    at process.exit (node:internal/process/per_thread:187:24)
    at /Users/macpro/.npm/_npx/a712338f43e79bae/node_modules/create-expo-app/build/index.js:77:736
    at <anonymous>
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (/Users/macpro/.npm/_npx/a712338f43e79bae/node_modules/create-expo-app/build/index.js:77:704) {
  code: 'ERR_INVALID_ARG_TYPE'
}

排查与修复步骤

  • 验证npm安装与环境变量配置
    终端执行npm -v,若提示命令不存在,说明npm未安装或未加入系统PATH。重新安装Node.js(npm随Node.js分发),安装完成后重启终端再试。
  • 清除npx缓存
    执行npx clear-npx-cache清除缓存文件后,重新运行npx create-expo-app。
  • 指定create-expo-app最新版本
    执行npx create-expo-app@latest,避免版本兼容问题。
  • 检查系统PATH
    Mac终端执行echo $PATH,确认输出包含/usr/local/bin(默认npm安装路径)或Node.js实际安装目录。若未包含,手动将路径添加到环境变量配置文件(如~/.zshrc或~/.bash_profile)后生效。
  • 切换包管理器尝试
    若npm问题未解决,已安装yarn或pnpm的情况下,可执行yarn create expo-app或pnpm create expo-app创建项目。

内容的提问来源于stack exchange,提问作者Lish

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 09:32:05