代码之家  ›  专栏  ›  技术社区  ›  mermaid

eas:术语“eas”未被识别为cmdlet、函数、脚本文件或可操作程序的名称-expo

  •  0
  • mermaid  · 技术社区  · 2 年前

    在我错误地编辑了一些用户变量之前,开发构建的每一件事都很顺利。

    则所有eas命令都以此错误结束:

    eas : The term 'eas' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was 
    included, verify that the path is correct and try again.
    At line:1 char:1
    + eas login
    + ~~~
        + CategoryInfo          : ObjectNotFound: (eas:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    

    我试过了 npm install -g eas-cli npm uninstall -g eas

    没有起作用

    0 回复  |  直到 2 年前
        1
  •  0
  •   mermaid    2 年前

    我在将这些路径添加到系统变量后修复了它

    1_ C:\Users\YourPcName\AppData\Roaming\npm 我把它移到所有其他路径的顶部

    2_ C:\Users\YourPcName\AppData\Roaming\npm\node_modules\eas-cli\bin

        2
  •  0
  •   mklement0    2 年前

    你的问题归结为如何 修复的持久定义 PATH 环境变量 因此 已安装CLI 全球地 具有 npm install -g 可以 再次被调用 仅限姓名 例如 eas 在你的情况下。

    为此,请确保 目录路径输出者 npm prefix -g -通常 "$env:APPDATA\npm" -是 的一部分 用户级别 的定义 路径 注册表中的环境变量 . [1]

    • 注意:您只需要添加 这个 目录-它是入口点所在( *.cmd .ps1 文件和Unix shell脚本) 全部的 放置全局安装的CLI。

    自动化 过程:

    $globalClisDir = npm prefix -g
    
    # Make sure the directory is listed in the *persistent, user-level* definition
    # of the PATH env. var. in the registry.
    if (([Environment]::GetEnvironmentVariable('Path', 'User') -split ';' -eq $globalClisDir).Count -eq 0) { 
      # Important: Get the current definition in *unexpanded* form directly
      #            from the registry.
      $userPathRaw = 
        (Get-Item HKCU:\Environment).GetValue('Path', $null, 'DoNotExpandEnvironmentNames')
      # Update it with the directory appended.
      Set-ItemProperty HKCU:\Environment Path "$userPathRaw;$globalClisDir" 
    }
    

    注:

    • 更新的 路径 值将在中生效 将来 PowerShell会话,但您需要与Windows外壳程序通信环境变量已更改:

      • 在最简单的形式中,强制重新启动所有 explorer.exe 窗户:

        Stop-Process -Name explorer
        
      • 有关更温和的方法,请参阅下面的链接答案。

    • 还要为更新它 现在的 会话,运行:

        $env:PATH+=";$(npm prefix -g)"
      
    • 的唯一目的 if 语句是为了防止意外添加目录 倍数 时间。

    • This answer 解释为什么更新很重要 Path -和其他环境变量,定义为 REG_EXPAND_SZ 注册表值-直接通过注册表,以及 使用诸如 setx.exe 或者 [System.Environment]::SetEnvironmentVariable() .NET API。


    [1] 由于全局安装的npm包放置在 用户特定位置 (其他用户通常无法访问),只修改用户级别是有意义的 路径 释义

    推荐文章