首页 > 解决方案 > Windows PowerShell 在 Windows 10 上安装 NativeScript

问题描述

我尝试从 Admin PowerShell 控制台在 Windows 10 上安装 NativeScript。

https://docs.nativescript.org/start/ns-setup-win

我键入此命令并获得以下错误:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://nativescript.org/setup/win-avd'))"

10

标签: powershellnativescript

解决方案


当您需要从 CMD 命令提示符运行该命令时,您正在从 PowerShell 运行该命令。

从 CMD 运行:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://nativescript.org/setup/win-avd'))"

在这里,@powershell意思是“不要回显命令并运行 powershell.exe”。这在 PowerShell 本身中意味着完全不同的东西,这意味着“搜索路径并使用扩展@powershell名之前的文字名称执行程序”或“将变量用作 splat 变量”,具体取决于您的 PowerShell 版本。 @powershell$powershell

如果你在 Powershell 中运行它,你只需要运行:

iex ((new-object net.webclient).DownloadString('https://nativescript.org/setup/win-avd'))

与往常一样,在运行这些下载任意代码并立即执行的命令时要格外小心。


推荐阅读