【问题标题】:How to update nativescript cli如何更新 nativescript cli
【发布时间】:2019-04-07 16:05:42
【问题描述】:

Nativescript 5 已经发布,我正在尝试更新 tns 版本。目前它 tns --version 显示为 4.3.2。

我遵循了https://docs.nativescript.org/releases/upgrade-instructions 中的所有步骤,但它仍然给我提供了 4.3.2 的版本。

如何升级 nativescript-cli 以便 tns --version 显示最新版本。

【问题讨论】:

    标签: nativescript npm-install nativescript-cli


    【解决方案1】:

    我做了以下以反映更新 Nativescript cli。只有当 npm install -g nativescript@latest 不反映更新 cli 时,您才应遵循此操作。您可以在前后使用 tns --version 进行检查。

    1. 使用 npm uninstall -g nativescript 卸载当前的 nativescript cli
    2. 如果现有的 tns 命令仍然存在于您的计算机上,请手动删除它。
    3. 使用 npm install -g nativescript@latest 安装最新的 Nativescript cli
    4. tns --version 现在应该显示最新版本。

    【讨论】:

    • 如果我的机器上仍然存在现有的 tns 命令,如何手动删除它?
    • 在您的机器上搜索 tns.exe 文件并将其删除。您还可以检查 PATH 变量下的所有位置。
    • 我成功了。我在 Linux 上,所以我搜索了 tns 并在所有地方删除了它。非常感谢
    • 很高兴听到这个消息!
    【解决方案2】:

    我是如何更新 tns 的:

    1. 以管理员身份运行 cmd(您使用的是我在上面的 cmets 中读到的 windows)
    2. (可选)运行 npm view nativescript version 以检查 npm 上的最新可用
    3. 运行tns install -g nativescript
    4. 重启cmd
    5. 运行tns --version - 希望你会看到5.0.0

    希望这会有所帮助。

    顺便说一句,如果您已经添加了platforms,您可能需要为您的项目运行一些额外的命令 tns platform remove {platform}

    tns platform add {platform},其中{platform}androidios

    ...另外,您可能会在升级后运行tns doctor,因为我注意到它破坏了我的其他组件,例如choco

    【讨论】:

    • 我想你的意思是npm install -g nativescript而不是tns install -g nativescript
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    • 2017-10-21
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    相关资源
    最近更新 更多