4

我是 NativeScript 的新手,目前正在执行此处描述的安装步骤 ( http://docs.nativescript.org/angular/tutorial/ng-chapter-1 ),我刚刚完成了 PowerShell 脚本的执行

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/NativeScript/nativescript-cli/production/setup/native-script.ps1'))"

然后我跑

tns doctor 

我得到

 C:\>tns doctor 'tns' is not recognized as an internal or external command, operable program or batch file.
4

4 回答 4

11

使用此代码

npm install --global nativescript

我有同样的问题,安装nativescript解决了它。

于 2020-01-29T07:55:43.023 回答
8

如果您使用的是 Windows,则需要将 npm 全局目录添加到您的路径中。

  1. 控制面板 -> 系统
  2. 高级系统设置(左侧链接)
  3. 环境变量(按钮)
  4. 向下滚动路径,然后单击编辑(按钮)
  5. 追加到最后:;%USERPROFILE%\AppData\Roaming\npm

确保你得到分号。

这应该适用于 Windows 7。我可以为您提供其他版本的 Windows 的步骤;但希望这能让你继续前进。

于 2018-07-01T02:46:07.153 回答
0

我试图使用nativescript和安装角度模块创建一个带有角度的移动应用程序npm install --global @nativescript/schematics

遵循https://blog.angular.io/apps-that-work-natively-on-the-web-and-mobile-9b26852495e7中提到的所有说明

毕竟,我遇到了同样的错误。

'tns' 不是内部或外部命令、可运行程序或批处理文件。

但它通过全局安装 nativescript 模块得到了解决。

npm install --global nativescript

或者

npm install -g nativescript

之后,我能够正确使用tns

希望这将帮助您解决您的问题。

于 2020-05-09T17:42:30.917 回答
0

转到C:\Users\\username\AppData\Roaming\npm\node_modules(适当地替换username)并检查是否安装了 Nativescript。如果没有创建目录并安装 nativescript 并从 node_modules 复制 nativescript 目录并粘贴到里面C:\Users\username\AppData\Roaming\npm\node_modules

创建 C:\Users\username\AppData\Roaming\npm\ tns.cmd文件并复制以下内容

@IF EXIST "%~dp0\node.exe" (
    "%~dp0\node.exe" "%~dp0\node_modules\nativescript\bin\tns" %*
) ELSE (
    @SETLOCAL
    @SET PATHEXT=%PATHEXT:;.JS;=;%
    node "%~dp0\node_modules\nativescript\bin\tns" %*
)
于 2017-11-20T08:02:26.043 回答