'tns' is not recognized as an internal or external command, operable program or batch file. NativeScript
Asked Answered
I

4

7

I am new to NativeScript and am currently going through the installation steps described here (http://docs.nativescript.org/angular/tutorial/ng-chapter-1) and I just completed executing the PowerShell script

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

and then I run

tns doctor 

and I get

 C:\>tns doctor 'tns' is not recognized as an internal or external command, operable program or batch file.
Imperfective answered 5/5, 2016 at 0:13 Comment(2)
this is step 3 in the tutoriall... step 2 is instaliing tns - did you run the command "npm install -g nativescript" (in order to run npm you shouyld have installed Node.js version 4.x or 5.x)Vadose
In my case I have already installed nativescript using the command above and now attempting to run the same command seems to make npm hang.Aback
S
13

Use this code

npm install --global nativescript

I had the same isssue and installing nativescript solved it.

Scalene answered 29/1, 2020 at 7:55 Comment(3)
This is an answer. I had the same problem and I solved it by installing nativescript globallyAshe
Please add a bit of explanation and I will revise my review.Chalcedony
Cant able to install tns. as tns required node8.x and Node team officially ended node 8 supportLamblike
I
8

If you are on Windows you need to add the the npm global directory to your path.

  1. Control Panels -> System
  2. Advanced System Settings (Link on Left side)
  3. Environmental Variables (Button)
  4. Scroll down for Path, and then click Edit (Button)
  5. Append to the end: ;%USERPROFILE%\AppData\Roaming\npm

Make sure you get the semicolon.

This should work on Windows 7. I can get you the steps for other versions of windows; but hopefully this gets you going.

Impulsive answered 1/7, 2018 at 2:46 Comment(0)
T
1

I was trying to create a mobile app with angular using nativescript and Install angular module npm install --global @nativescript/schematics

followed all instruction as mention in https://blog.angular.io/apps-that-work-natively-on-the-web-and-mobile-9b26852495e7

after everything, I faced the same error.

'tns' is not recognized as an internal or external command, operable program or batch file.

But it got resolved by installing nativescript module globally.

npm install --global nativescript

or

npm install -g nativescript

After that, I was able to use tns properly.

Hope this will help you to resolve your issue.

Tull answered 9/5, 2020 at 17:42 Comment(0)
R
0

Go to C:\Users\\username\AppData\Roaming\npm\node_modules (replace username appropriately) and check if Nativescript is installed or not. If not create directory and install nativescript and copy nativescript dir from node_modules and paste inside C:\Users\username\AppData\Roaming\npm\node_modules

create C:\Users\username\AppData\Roaming\npm\tns.cmd file and copy below content

@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" %*
)
Ryun answered 20/11, 2017 at 8:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.