Search code examples
command-linenativescript

why installing nativescript gives that tns is not recognized as the name of a cmdlet?


I m trying to install nativescript, when I do the npm install it works fine but after that when I try to

tns doctor or tns create

it gives me this message:

The term 'tns' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again nativescript

Someone told me that it is probably something with the environment variables but if so i m not sure what needs to be done


Solution

  • I solved the problem by copying the nativescript node modules to C:\Users\username\AppData\Roaming\npm\node_modules and then creating a file called tns.cmd in C:\Users\username\AppData\Roaming\npm that has the following:

    @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" %* )

    and then it worked