我是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.
使用此代码
npm install --global nativescript
我有同样的问题,安装nativescript
解决了它。
如果您在Windows上,则需要将npm全局目录添加到您的路径中。
- 控制面板->系统
- 高级系统设置(左侧链接)
- 环境变量(按钮)
- 向下滚动"路径",然后单击"编辑"(按钮)
- 追加到末尾:
;%USERPROFILE%AppDataRoamingnpm
确保你得到了分号。
这应该适用于Windows7。我可以为您提供其他版本窗口的步骤;但希望这能让你继续前进。
我试图使用nativescript创建一个带有angular的移动应用程序并安装angular模块npm install --global @nativescript/schematics
遵循中提到的所有说明https://blog.angular.io/apps-that-work-natively-on-the-web-and-mobile-9b26852495e7
毕竟,我面临着同样的错误。
"tns"未被识别为内部或外部命令、可操作程序或批处理文件。
但通过在全局范围内安装nativescript模块解决了这个问题。
npm安装-全局本机描述
或
npm install-g nativescript
在那之后,我能够正确地使用tns。
希望这能帮助你解决你的问题。
转到C:Users\usernameAppDataRoamingnpmnode_modules
(适当替换username
)并检查是否安装了Nativescript。如果没有创建目录并安装nativescript,则从node_modules复制nativescript-dir并粘贴到C:UsersusernameAppDataRoamingnpmnode_modules
中
创建C:\Users\username\AppData\Roaming\npm\tns.cmd文件并复制以下内容
@IF EXIST "%~dp0node.exe" (
"%~dp0node.exe" "%~dp0node_modulesnativescriptbintns" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0node_modulesnativescriptbintns" %*
)