Nativescript-cli: Error occurs while installing nativescript (npm install nativescript -g)

Created on 6 Dec 2016  Â·  9Comments  Â·  Source: NativeScript/nativescript-cli

Hi ,

i got that error when trying installing nativescript

=> npm install nativescript -g


npm WARN deprecated [email protected]: use uuid module instead
npm WARN excluding symbolic link docs/stylesheets/hightlight.css -> ../../node_modules/highlight.js/src/styles/solarized_light.css
npm WARN excluding symbolic link docs/assets/ir_black.css -> ../../node_modules/highlight.js/src/styles/ir_black.css
npm WARN excluding symbolic link examples/TestFramework/Test Framework.framework/Resources -> Versions/Current/Resources
npm WARN excluding symbolic link examples/TestFramework/Test Framework.framework/Test Framework -> Versions/Current/Test Framework
npm WARN excluding symbolic link examples/TestFramework/Test Framework.framework/Versions/Current -> A
npm WARN deprecated [email protected]: This package is discontinued. Use lodash@^4.0.0.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: use uuid module instead

> [email protected] preuninstall /Users/sc/.npm-global/lib/node_modules/nativescript
> node preuninstall.js

Failed to complete all pre-uninstall steps. 
/Users/sc/.npm-global/bin/nativescript -> /Users/sc/.npm-global/lib/node_modules/nativescript/bin/nativescript.js
/Users/sc/.npm-global/bin/tns -> /Users/sc/.npm-global/lib/node_modules/nativescript/bin/nativescript.js

> [email protected] postinstall /Users/sc/.npm-global/lib/node_modules/nativescript
> node postinstall.js

The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
To be able to perform Android build-related operations, set the ANDROID_HOME variable to point to the root of your Android SDK installation directory.

WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to build your projects for Android and run them in the native emulator.
To be able to build for Android and run apps in the native emulator, verify that you have
installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.

Verifying CocoaPods. This may take more than a minute, please be patient.
  â—¡ Installing iOS [email protected] /var/folders/9k/g9328xl91q5gw5fhs1kdq6mm0000gn/T/nativescript-check-cocoapods116116-4512-14he8kq.cjpoa5g66r/node_modules/tns-ios
  ◜ Verifying CocoaPods. This may take some time, please be patient..
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run $ android to manage your Android SDK versions.

You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=25'.
Run android from your command-line to install required Android Build Tools. In case you already have them installed, make sure ANDROID_HOME environment variable is set correctly.

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run $ android  to manage the Android Support Repository. In case you already have it installed, make sure ANDROID_HOME environment variable is set correctly.
question

All 9 comments

Hello @silentscoders

From the error log it seems that there might be several reasons for this to happen.
You need to have pre-installed and set:

  • JDK 8 or a later stable official release
  • Android SDK 22 or a later stable official release
  • environment paths set for ANDROID_HOME and JAVA_HOME
  • Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=25'.
  • Android Support Repository installed

One of the lines in your error log suggest the following:

The ANDROID_HOME environment variable is not set or it points to a non-existent directory.

Which suggest that in your system you do not have Android SDK installed and /or path set

Also notice the last lines from the error log:

You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=25'.
Run android from your command-line to install required Android Build Tools. In case you already have them installed, make sure ANDROID_HOME environment variable is set correctly.

You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run $ android to manage the Android Support Repository. In case you already have it installed, make sure ANDROID_HOME environment variable is set correctly.

Thank you @NickIliev

what about that error
"npm WARN deprecated [email protected]: use uuid module instead
npm WARN excluding symbolic link docs/stylesheets/hightlight.css -> ../../node_modules/highlight.js/src/styles/solarized_light.css
npm WARN excluding symbolic link docs/assets/ir_black.css -> ../../node_modules/highlight.js/src/styles/ir_black.css
npm WARN excluding symbolic link examples/TestFramework/Test Framework.framework/Resources -> Versions/Current/Resources
npm WARN excluding symbolic link examples/TestFramework/Test Framework.framework/Test Framework -> Versions/Current/Test Framework
npm WARN excluding symbolic link examples/TestFramework/Test Framework.framework/Versions/Current -> A
npm WARN deprecated [email protected]: This package is discontinued. Use lodash@^4.0.0.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: use uuid module instead
"

Hey @silentscoders what is the version of your Node.js

node --version

I would recommend upgrading your Node.js version to the latest stable version. Currently, this is 6.9.2

Hi @NickIliev it's already v6.9.2

We will update the old versions at some point but at the moment they haven't been causing troubles.

I am getting the following error:

Unexpected token in JSON at position 0
Failed to display command help SyntaxError: Unexpected token in JSON at position 0
at Object.parse (native)
at FileSystem.readJson (C:\Users\sacnaik\AppData\Roaming\npm\node_modules\nativescript\lib\common\file-system.js:167:25)
at UserSettingsService. (C:\Users\sacnaik\AppData\Roaming\npm\node_modules\nativescript\lib\common\services\user-settings-service.js:55:50)
at next (native)
at C:\Users\sacnaik\AppData\Roaming\npm\node_modules\nativescript\lib\common\services\user-settings-service.js:7:65
at __awaiter (C:\Users\sacnaik\AppData\Roaming\npm\node_modules\nativescript\lib\common\services\user-settings-service.js:3:12)
at UserSettingsService.loadUserSettingsFile (C:\Users\sacnaik\AppData\Roaming\npm\node_modules\nativescript\lib\common\services\user-settings-service.js:50:16)
at UserSettingsService. (C:\Users\sacnaik\AppData\Roaming\npm\node_modules\nativescript\lib\common\services\user-settings-service.js:19:24)
at next (native)

Hey @srnaik ,
Can you check your %APPDATA%\.nativescript-cli\user-settings.json - it looks like there's some strange symbols in it. You can try deleting it - CLI will recreate it for you, but can you please check the content and send it to us, so we can investigate it further?

Hi @rosen-vladimirov,

You are correct, It had contained some strange symbols (NULL NULL NULL), I deleted and tried to install it again, and this time I was able to install properly, Thank you very much for your help, I truly appreciate your help, you guys are very responsive to all my questions, that is really great !

thank you very much @rosen-vladimirov .
I also geting same error here and solve it.

Was this page helpful?
0 / 5 - 0 ratings