Perpetual NativeScript Mac Installation Issues - node.js

I could really use someone's help on this as I have been troubleshooting this for a really long time now with no remediation.
The issue is simply installing the NativeScript CLI onto my OSX Yosemite Mac. I followed the steps according to NS' website (installing proper Node.JS version, downloaded Xcode 7.2 (due to OS constraints), installed JSDK, installed NS Sidekick, installed Android Studio w/ proper SDK along with every other required dependancy.
However, when I run "sudo npm i -g nativescript --unsafe-perm" (otherwise it will throw a EACCES error), I get the following log with it saying I missing all of these dependencies I know I have but it is claiming I don't.
The biggest kick is that while it still will say NativeScript successfully installed, whenever I run any tns command (like tns doctor), the bash command cannot be found.
I have made sure to follow the directions of adding NS to my path as well as my Android and Java SDKs. Here is the full log:
jsmbp:~ Js$ sudo npm i -g nativescript --unsafe-perm
Password:
/Users/Jmsquillaro/.npm-packages/bin/nativescript -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns
/Users/Jmsquillaro/.npm-packages/bin/tns -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns
> fsevents#1.1.2 install /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents
> node install
[fsevents] Success: "/Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> nativescript#3.3.1 postinstall /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript
> node postinstall.js
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.
WARNING: CocoaPods is not installed or is not configured properly.
You will not be able to build your projects for iOS if they contain plugin with CocoaPod file.
To be able to build such projects, verify that you have installed CocoaPods.
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.
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run $ sdkmanager 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 <=26'.
Run $ sdkmanager 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 $ sdkmanager to manage the Android Support Repository. In case you already have it installed, make sure ANDROID_HOME environment variable is set correctly.
Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements
There seem to be issues with your configuration.
? Do you want to visit the official documentation? No
? Do you want to run the setup script? No
Your components are up-to-date:
nativescript,tns-core-modules,tns-android,tns-ios
Autocompletion is already enabled
Installation successful. You are good to go. Connect with us on http://twitter.com/NativeScript.
+ nativescript#3.3.1
added 692 packages in 156.18s
jsmbp:~ Js$ tns doctor
-bash: tns: command not found
What can I do to fix this? npm also declares "rollbackFailedOptional" every time I try to reinstall after I uninstall it. Is npm caching a broken version and can I force it to do a genuine "reinstall?" It has been so frustrating as everything looks messed up and I really don't want to give up on NS. Let me know your thoughts and thank you!

Begin by installing node.js correctly. I've you are having to you --unsafe-perm that means, the node.js installation is not done right.
I suggest you install nvm using homebrew and then install node from that. Please refer to my solution in this post https://discourse.nativescript.org/t/not-installing-on-macos/3292/4

Related

ANDROID_SDK_ROOT=undefined (recommended setting) while building ionic app using Cordova for Android device

I am trying to build an ionic app for Android device with Cordova using the below command from VSCode.
ionic cordova build android --prod --release
But I'm getting this error:
cordova.cmd build android --release
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\tanmay\AppData\Local\Android\sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --release exited with exit code 1.
I have already installed JDK, Android Studio. I also have setup the environment variable ANDROID_SDK_ROOT with the correct SDK path. But still no luck.
I am using
Android Studio 3.6.1,
Gradle 6.3,
Cordova 8.1,
on Windows 10.
I guess I am somewhere missing the setting the ANDROID_SDK_ROOT but I'm not sure where.
You can check if Java JDK, Android SDK, Gradle are properly installed before building an app.
To do so, you can run the following command :
cordova requirements android --verbose
It will show, what is missing and after that, you may install it if you haven't installed it or you may check for the correct path in the Environment Variables.
If you have an android studio installed, you need not to worry about this error on terminal, as until this error cordova will update your android package in platforms directory.
Open your Android Studio.
Select open existing project and browse to select your /platforms/android folder in
project directory.
It will open in android and will be build success
I had the same error.
I solved it by using Gradle 5.6.3 instead of the newer versions.
For anyone as dumb as I was that also thought you could setup and run a cordova project on android without having java, gradle or android studio installed: Once you installed all those things, delete your cordova project's node_modules, platforms, plugins and www folders and set them up again (i.e. rerun npm i, cordova platform add android, npm run build, etc) before trying to run the cordova project again. In my case I'm trying to run cordova run android which caused the same error that OP's getting.
NOTE: I have zero experience with cordova. I have to get a very specific cordova/webpack template up and running locally, and the advice I'm giving in this answer is what worked for me. YMMV.

Ionic setup issues on Windows 7

I am trying to install Ionic on Windows 7 machine.
First, installed NodeJS 6.1.0, It went fine
Then, ran npm install -g cordova, Went fine
Then, ran npm install -g ionic, Got error related to Python.
Installed Python 2.7
Again, ran npm install -g ionic, Got error related to Microsoft .Net
Framework 2 SDK.
Updated npm to 3.8.9, Still getting error related to Microsoft .Net
Framework 2 SDK.
Are Python and Microsoft .Net SDK actually required? Nowhere I could find about this in the installation guides.
no python and .net SDK are not required
you need to download Android SDK in the case of developing for android.
you can download android studio and download SDK from SDK MANAGER or simply download android SDK. In my case, I download the android studio and then used the SDk manager to download the SDK's.
You can download it from here Android SDK
Also ou need to have JAVA jdk installed on your system and you have to set
PATH for both android sdk , java and nodejs
add PATH in system variables to environment variable
to
C:\Program Files\nodejs\
C:\Users**SystemName**\AppData\Local\Android\android-sdk\tools
C:\Users**SystemName**\AppData\Local\Android\android-sdk\platform-tools
C:\Program Files\Java\jdk1.7.0_79\bin
the above paths are according to my system. The SystemName may differ on your system else will be the same.
You also need to set User Variable jsut above your system variable:
ANDROID_HOME : C:\Users\SystemName\AppData\Local\Android\android-sdk
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_79
you may also need to install gradle using nodejs command
and add its user variable and system variable
like
GRADLE_HOME :C:\Program Files\gradle-2.9
same in system variable(i.e PATH)
But first of all you need to download Node.js
I tried v6.0.1 but it is not compatible for ionic 2 for now, so you can download v4.4.x or v5.x from Node js site(sorry dont have 10 repo poits to post the third link) for now and later use v6.0.x
now using nodejs command prompt you need to install npm http://blog.npmjs.org/post/85484771375/how-to-install-npm
after installing npm
install ionic 2 and cordova using
npm install -g ionic#beta cordova
now Ionic is installed on your system.
To start a new project
ionic start Myproject --v2
and if you want to start a ionic project using typescript
ionic start Myproject --v2 --ts
Now give command
cd Myproject
to go to the directory of your project
after that, to test your app use
ionic serve

Cordova: You may not have the required environment or OS to run this project

On Linux Mint 17.1 x86_64, Cordova v4.3.0 gives this error:
$ cordova run android
Running command: /home/naman/test/platforms/android/cordova/run
WARNING : No target specified, deploying to emulator
WARNING : no emulator specified, defaulting to Sample
Waiting for emulator...
Booting up emulator (this may take a while)....BOOT COMPLETE
/home/naman/test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error: ENOENT, no such file or directory '/opt/software/android-sdk/tools/tools/lib/build.template'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at /home/naman/test/platforms/android/cordova/lib/build.js:129:40
at _fulfilled (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:760:13)
at /home/naman/test/platforms/android/cordova/node_modules/q/q.js:574:44
at flush (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
ERROR running one or more of the platforms: Error: /home/naman/test/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project
PATH variable seems to be alright (the path for SDK is correct):
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/software/android-sdk/tools:/opt/software/android-sdk/platform-tools
I installed it using :
sudo apt-add-repository ppa:cordova-ubuntu/ppa
sudo apt-get update
sudo apt-get install cordova-cli
npm install -g cordova
The installation went smoothly and the project was created without any error.
Am I missing some dependency?
You may need to uninstall the existing app on your device.
I installed my app on that device from another computer. When I run cordova run android I get
You may not have the required environment or OS to run this project.
But when I try to install my apk by adb it told my that the app was already installed. So I uninstalled it an it worked.
For others having this problem, assuming you have already checked and fixed any environment variables using #Naman Dixit's answer, you may also have to remove and add your platforms:
cmd: cordova platform rm [platform(s) of interest]
delete everything in the [yourproject]/platforms folder. Then:
cmd: cordova platform add [platform(s) of interest]
that was the final step I needed to get everything to work
Make sure you have proper environment variables defined (add this in .bash_login or .profile and do source .profile):
export ANDROID_SDK="/opt/software/android-sdk"
export ANDROID_NDK="/opt/software/android-ndk"
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK/platform-tools"
export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS"
Your android sdk doesn't seem to be properly installed or you didn't install the proper android sdk version that has the dependency that you seem to be missing
/opt/software/android-sdk/tools/tools/lib/build.template
I encountered this issue now too. The problem in my case is that the ant.properties file that I'm using is pointed to wrong and NOT existing file.
key.store=D:/Fedmich/_keys/android.keystore
After correcting it, I was able to compile a release apk.
Hope this helps someone in the future. Just be sure to read the error_logs that is given in the command prompt.
This is just to have one more reason for this error documented here and for them who are still searching for solution.
When I came accross this error, I tried almost all the solutions listed on the stackoverflow.
My issue was my device was not getting detected by adb, adb kill-server/start-server also not helped me, ***
but changing USB port helped.
I got a same error
my solution is underlying.
command adb device
no result.....
install usb drive for mobile (my phone is lg g3)
reeboot and command adb device again : result device showing.
then tried again
3. ionic run adnroid --device
"OK";
Happens when platform is added without internet connection.
Ensure internet is OK and type :
cordova platform remove blackberry10
cordova platform add blackberry10
Try to build and run :
cordova run
Hope this fix your problem, also for other platform
I got this error after installing the Crosswalk plugin. To solve it I installed the latest Android SDK, deleted the android folder under platforms and ran
phonegap build android
alternatively
cordova platform add --save android
cordova build android
and it was all good.
I had the same error building the android platform, and no solution given here could help me.
I decided to run the gradlew command shown by cordova, and saw there was a problem with a png file included in the cordova project.
After removing it, I managed building the platform again.
export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140321/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
then cordova run android works
Ubuntu
If you are having issues on Ubuntu, you may want to try installing the following packages, per the docs:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386
You may also need to install this package:
sudo apt-get install lib32z1

How to use a different version of Npm and Cordova

We have downloaded and installed a different Npm instance outside Visual Studio on our development machine and set the system classpath to use this version;
using this Npm, we have downloaded the latest version of Cordova (3.5.0).
Apparently, it seems that Visual Studio 2013 is using this new Npm installation and Cordova version when building; using this configuration we can correctly build and deploy to WP8, Android and iOS.
Also the plugins (enabled from the config.xml in VS) are downloaded and set in the new Cordova path.
Looking at the build log, I've however noticed that the iOS build is reporting that the 3.4.0 version of Cordova is used.
Is this kind of configuration supported?
Which is the correct way to use a different version of Cordova?
If you update Multi-Device Hybrid Apps to the CTP2, Visual Studio now uses Cordova 3.5.0 instead of 3.4.1. You should also update your instance of vs-mda-remote on your Mac to stay in sync for iOS.
There is currently not a supported way to select a version of Cordova though that is on the roadmap.

NPM - Can't install socket.IO

I am trying to install socket.io on windows with npm for use on a nodeJS server.
First, when I typed "npm install socket.IO" i had an error in the log saying something about python and node-gyp. I installed python 2.7.3 and set the environment variables.
Now I got a new error, which has something to do with visual studio (what the hell does VS have to do with npm ? Is it about the compiler? ).
The error is the same as here npm install for some packages (sqlite3, socket.io) fail with error MSB8020 on Windows 7
But when I use the option in the answer instead of the error it tells me something about a possible data loss (c4267) but doesn't log any error.
Then when I start my app, it tells me cannot find module socket.io still
What could this come from ?
Oh and also when i do npm config get root it tells me "undefined" could it have anything to do with it ?
Should I install the modules globally or locally ?
At least one of the packages in Socket.IO's dependency tree is a C/C++ addons which needs to be compiled on your system as it's installed. And, since it's a dependency, if it doesn't succeed in installing, neither will Socket.IO.
To enable cross-system compilation, Node.js uses node-gyp as its build system. You'll need to have it installed as a global package:
npm install -g node-gyp
As well as have its dependencies installed. Abridged version:
Python 2
C/C++ Compiler / Build Tools
For Windows, Microsoft Visual Studio 2013 (C++ or Windows Desktop) (Express edition)
For 64-bit, may need Windows 7 64-bit SDK
Then, you should be able to install Socket.IO as a local package so you can require it:
npm install socket.io
I had a similar problem on Mac.
What resolved my problem is installing a slightly older version of Socket.io.
I did:
npm install socket.io#"~0.8.1"
which would install the latest version between 0.8.0 to 0.8.9, but not 0.9.0 or above.
Socket.io then installed perfectly.
Make sure you have all the required software to run node-gyp:
https://github.com/TooTallNate/node-gyp
You can configure version of Visual Studio used by gyp via an environment variable so you can avoid having to set the --msvs_version=2012 property.
Examples:
set GYP_MSVS_VERSION=2012 for Visual Studio 2012
set GYP_MSVS_VERSION=2013e (the 'e' stands for 'express edition')
For the full list see
- https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294
This is still painful for Windows users of NodeJS as it assumes you have a copy of Visual Studio installed and many end users will never have this. So I'm lobbying Joyent to the encourage them to include web sockets as part of CORE node and also to possible ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem.
Feel free to add your vote at:
https://github.com/joyent/node/issues/8005#issuecomment-50545326
The problem causing the compile failure is that the ws module installed by the engine.io module required by socket.io pulls in a backlevel version of nan. See https://github.com/BrowserSync/grunt-browser-sync/issues/95 for details. To work around the problem after the build failure:
cd to node_modules/socket.io/node_modules/engine.io/node_modules/ws
edit package.json to change the release of nan from 1.4.x to 1.6.0
issue command node-gyp rebuild
You should now be able to use socket.io
Another approach is to use Docker for Windows and spin up a NodeJS environment. While developing you can mount your Node code as a Docker volume and so continue to update your code from Windows but execute it and install it's dependencies inside a Linux VM. When you deploy you might prefer to use a Dockerfile that COPY's your Node code into your Docker image and so bakes it into the release image you deploy.
This approach might be required if you don't want to risk changing the socket.io version of your code or its dependencies.
It also may be a valuable solution if you planned to deploy to a corporate Intranet or public/private Cloud.
Docker can also be very handy for testing deployment under different versions of Node without disturbing the development environment of your Windows computer (e.g. for testing a NodeJS lib).
Official NodeJS Docker images
An explanation of how to use these images
this problem makes me very troubled..
I tried many solutions.
I installed .NET Framework 2.0 SDK.
I installed Python 2.7.x
I installed VS 2012 Express
I set some paths
I executed npm install xxx with the argument --msvs_version=2010(or 2012/2013..)...
But all failed.
finally, I uninstalled Python & .NET Framework 2.0 SDK & VS 2012, clear those paths,enable Windows Update, install all essential updates, restart my computer
then execute commands below:
npm install node-gyp -g
npm install socket.io -g
npm install browser-sync -g
there is no errors in installation logs.
Note : this solution may not work for you, but for me

Resources