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.
Robert Green MBA
  • 1,834
  • 1
  • 22
  • 45
  • 3
    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) – Nick Iliev May 05 '16 at 06:29
  • 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. – HK1 Jun 13 '16 at 23:48

4 Answers4

13

Use this code

npm install --global nativescript

I had the same isssue and installing nativescript solved it.

B--rian
  • 5,578
  • 10
  • 38
  • 89
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.

Sebastian D'Agostino
  • 1,575
  • 2
  • 27
  • 44
Dileep
  • 89
  • 1
  • 2
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.

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" %*
)
B--rian
  • 5,578
  • 10
  • 38
  • 89