永久 NativeScript Mac 安装问题

Posted

技术标签:

【中文标题】永久 NativeScript Mac 安装问题【英文标题】:Perpetual NativeScript Mac Installation Issues 【发布时间】:2018-05-19 20:20:27 【问题描述】:

我真的可以在这方面寻求他人的帮助,因为我已经对此进行了很长时间的故障排除而没有任何补救措施。

问题只是将 NativeScript CLI 安装到我的 OSX Yosemite Mac 上。我按照 NS 网站的步骤进行操作(安装正确的 Node.JS 版本,下载 Xcode 7.2(由于操作系统限制),安装 JSDK,安装 NS Sidekick,安装带有正确 SDK 的 android Studio 以及其他所有必需的依赖项。

但是,当我运行“sudo npm i -g nativescript --unsafe-perm”(否则它会引发 EACCES 错误)时,我会收到以下日志,其中显示我缺少我知道的所有这些依赖项,但是它声称我没有。

最大的问题是,虽然它仍然会说 NativeScript 已成功安装,但每当我运行任何 tns 命令(如 tns doctor)时,都找不到 bash 命令。

我已确保遵循将 NS 添加到我的路径以及我的 Android 和 Java SDK 的说明。这是完整的日志:

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

我能做些什么来解决这个问题?每次我在卸载它后尝试重新安装时,npm 也会声明“rollbackFailedOptional”。 npm 是否缓存了损坏的版本,我可以强制它进行真正的“重新安装”吗?一切看起来都一团糟,我真的不想放弃 NS,这太令人沮丧了。让我知道你的想法,谢谢!

【问题讨论】:

【参考方案1】:

从正确安装 node.js 开始。我有你不得不--unsafe-perm 这意味着,node.js 安装不正确。 我建议您使用自制软件安装nvm,然后从中安装节点。请参考我在这篇文章中的解决方案https://discourse.nativescript.org/t/not-installing-on-macos/3292/4

【讨论】:

所以我遵循了这个,现在当我调用它来安装 NS 时,npm 不起作用。当我使用你的最后一步安装节点时,我得到了这个:“nvm 与 npm config“前缀”选项不兼容:当前设置为“/Users/Jmsquillaro/.npm-packages”运行nvm use --delete-prefix v8.9.1 以取消设置。创建默认值别名:默认 -> 8.9.1 (-> v8.9.1)" 这里出了什么问题,这会解决整个问题吗?这是由 node.js 还是其他原因引起的? 在安装 nvm 之前是否卸载了之前安装的 node?​​span> 是的,并删除了与之相关的任何其他文件。 brew卸载节点也做了很好的衡量。在此过程之后哪个节点没有产生任何结果,所以我假设在遵循您的教程之前所有内容都已删除。 现在打印什么,node -vnpm -v 我运行了“nvm use --delete-prefix v8.9.1”,现在 node 和 npm 都可以工作,显示 node 的 v8.9.1 和 npm 的 5.5.1。但是,当我再次运行 NS 的安装时,我仍然收到 EACCES 错误,即使是作为 root 用户也是如此。当像我最初使用 --unsafe-perm 一样运行命令时,我得到了和以前一样的东西。我觉得 npm 只是在某处使用它的缓存版本。同样,这不是我的专业领域,所以我不确定。您认为还有什么其他方法可以解决这个问题,还是总体上存在严重错误?

以上是关于永久 NativeScript Mac 安装问题的主要内容,如果未能解决你的问题,请参考以下文章

Linux/Mac实现下alias重命名命令永久生效

如何在我的 Mac 上永久设置 SQL_MODE

如何在 Mac 上永久激活非管理员帐户的 XAMPP 的 apache 和 mysql

NativeScript 安装问题

mac怎么装免费office365

技巧02-环境搭建-pycharm-mac版本安装汉化