KaliLinuxインストールNativeScript環境
32790 ワード
NativeScriptのインストール
新版のnodejsをインストールします
kaliはnodejsを持っていますが、最新のものではないので、更新します.実行:
実行:
中国はnpmを訪問するのが遅いので、宝を洗うのを助けます.https://npm.taobao.org/
運転インストール:
実行:
今までandroidの環境を持っていませんでしたが、それを通じて必要なsdkをダウンロードすることができますので、後で言及します.あなたの仕事のカタログにgitを降りてください.
完了したら再度運転すれば成功します.
新版のnodejsをインストールします
kaliはnodejsを持っていますが、最新のものではないので、更新します.実行:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
結果:## Installing the NodeSource Node.js v6.x repo...
## Populating apt-get cache...
+ apt-get update
:1 http://mirrors.aliyun.com/kali sana InRelease
:2 http://mirrors.aliyun.com/kali-security sana/updates InRelease
:3 http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling InRelease [30.5 kB]
:4 http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling/main i386 Packages [14.2 MB]
:5 http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 InRelease
:6 http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 Release
:7 http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 Release.gpg [801 B]
:8 http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling/main amd64 Packages [14.2 MB]
28.5 MB, 3 20 (142 kB/s)
...
## Installing packages required for setup: apt-transport-https...
+ apt-get install -y apt-transport-https > /dev/null 2>&1
## You seem to be using Kali version kali-rolling.
## This maps to Debian "jessie"... Adjusting for you...
## Confirming "jessie" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_6.x/dists/jessie/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK
## Creating apt sources list file for the NodeSource Node.js v6.x repo...
+ echo 'deb https://deb.nodesource.com/node_6.x jessie main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_6.x jessie main' >> /etc/apt/sources.list.d/nodesource.list
## Running `apt-get update` for you...
+ apt-get update
:1 http://mirrors.aliyun.com/kali sana InRelease
:2 http://mirrors.aliyun.com/kali-security sana/updates InRelease
:3 http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling InRelease
:4 http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 InRelease
:5 http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 Release
:6 https://deb.nodesource.com/node_6.x jessie InRelease [3,914 B]
:7 http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 Release.gpg [801 B]
:8 https://deb.nodesource.com/node_6.x jessie/main Sources [760 B]
:9 https://deb.nodesource.com/node_6.x jessie/main amd64 Packages [961 B]
:10 https://deb.nodesource.com/node_6.x jessie/main i386 Packages [958 B]
7,394 B, 2 (3,059 B/s)
...
## Run `apt-get install nodejs` (as root) to install Node.js v6.x and npm
更新完了:実行:
apt-get install nodejs
結果: ...
...
:
libuv1 libxcb-randr0:i386 libxcb-shape0:i386 libxcb-xfixes0:i386
'apt autoremove' ( )。
:
nodejs
1 , 0 , 0 , 223 。
10.1 MB 。
37.5 MB 。
:1 https://deb.nodesource.com/node_6.x jessie/main amd64 nodejs amd64 6.9.1-1nodesource1~jessie1 [10.1 MB]
10.1 MB, 19 (531 kB/s)
(changelogs)...
( ... 390887 。)
.../nodejs_6.9.1-1nodesource1~jessie1_amd64.deb ...
nodejs (6.9.1-1nodesource1~jessie1) (4.3.1~dfsg-3) ...
nodejs (6.9.1-1nodesource1~jessie1) ...
man-db (2.7.5-1) ...
各バージョンを確認します.root@jimo:~# node -v
v6.9.1
root@jimo:~# nodejs -v
v6.9.1
root@jimo:~# npm -v
3.10.8
cnpmをインストールする中国はnpmを訪問するのが遅いので、宝を洗うのを助けます.https://npm.taobao.org/
運転インストール:
root@jimo:~# npm install -g cnpm --registry=https://registry.npm.taobao.org
結果:npm WARN deprecated has-color@0.1.7: Renamed to supports-color. If you're using chalk, upgrade to the latest version. https://github.com/chalk/supports-color
/usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm
/usr/lib
└─┬ cnpm@4.4.0
├── auto-correct@1.0.0
├── bagpipe@0.3.5
├── colors@1.1.2
├─┬ commander@2.9.0
│ └── graceful-readlink@1.0.1
├─┬ cross-spawn@0.2.9
│ └── lru-cache@2.7.3
├─┬ debug@2.2.0
│ └── ms@0.7.1
├── giturl@1.0.0
├─┬ npm@3.10.9
│ ├── abbrev@1.0.9
│ ├── ansi-regex@2.0.0
│ ├── ansicolors@0.3.2
│ ├── ansistyles@0.1.3
│ ├── aproba@1.0.4
...... n
バージョンを表示:root@jimo:~# cnpm -v
4.4.0
native escriptをcnpmでインストールします.実行:
root@jimo:~# cnpm install nativescript -g --unsafe-perm
結果:⠴ Installing nativescript@*install bufferutil from remote https://github.com/telerik/bufferutil/tarball/v1.0.1.3, may be very slow, please keep patience
install cli-table from remote https://github.com/telerik/cli-table/tarball/v0.3.1.2, may be very slow, please keep patience
install ffi from remote https://github.com/icenium/node-ffi/tarball/v2.0.0.3, may be very slow, please keep patience
install fibers from remote https://github.com/icenium/node-fibers/tarball/v1.0.13.1, may be very slow, please keep patience
install node-inspector from remote https://github.com/NativeScript/node-inspector/tarball/v0.7.4.1, may be very slow, please keep patience.......... n
そしてインストールが成功したかどうかを確認します.root@jimo:~# tns doctor
NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.
You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=24'.
Run android from your command-line to install required Android Build Tools.
There seem to be issues with your configuration.
? Do you want to visit the official documentation? No
Your components are up-to-date.
When you file an issue, these warnings will help the NativeScript team to investigate, identify, and resolve the report.
Please, ignore them if you are not experiencing any issues with NativeScript.
またはヘルプコマンドを表示します.root@jimo:~# tns -h
# NativeScript
┌─────────┬─────────────────────────────────────────────────────────────────────┐
│ Usage │ Synopsis │
│ General │ $ tns [Command Parameters] [--command ] │
│ Alias │ $ nativescript [Command Parameters] [--command ] │
└─────────┴─────────────────────────────────────────────────────────────────────┘
## General Commands
┌─────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Command │ Description │
│ help │ Shows additional information about the commands in this list in the browser. │
│ autocomplete │ Configures your current command-line completion settings. │
│ usage-reporting │ Configures anonymous usage reporting for the NativeScript CLI. │
│ error-reporting │ Configures anonymous error reporting for the NativeScript CLI. │
│ doctor │ Checks your system for configuration problems which might prevent the NativeScript CLI from working properly. │
│ info │ Displays version information about the NativeScript CLI, core modules, and runtimes. │
└─────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
## Project Development Commands
┌────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Command │ Description │
│ create │ Creates a new project for native development with NativeScript. │
│ init │ Initializes an existing project for native development with NativeScript. │
│ platform add │ Configures the current project to target the selected platform. │
│ platform list │ Lists all platforms that the project currently targets. │
│ platform remove │ Removes the selected platform from the platforms that the project currently targets. This operation deletes all platform-specific files and subdirectories from your project. │
│ platform update │ Updates the NativeScript runtime for the specified platform. │
│ prepare │ Copies relevant content from the app directory to the subdirectory for the selected target platform to let you build the project. │
│ build │ Builds the project for the selected target platform and produces an application package or an emulator package. │
│ deploy │ Deploys the project to a connected physical or virtual device. │
│ emulate │ Deploys the project in the native emulator for the selected target platform. │
│ run │ Runs your project on a connected device or in the native emulator, if configured. │
│ debug │ Debugs your project on a connected physical or virtual device. │
│ test init │ Configures your project for unit testing with a selected framework. │
│ test │ Runs the unit tests in your project on a connected physical or virtual device. │
│ install │ Installs all platforms and dependencies described in the package.json file in the current directory. │
│ plugin │ Lets you manage the plugins for your project. │
│ livesync │ Synchronizes the latest changes in your project to devices. │
└────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
## Publishing Commands
┌─────────────────┬──────────────────────────────────────────────────┐
│ Command │ Description │
│ appstore │ Lists applications registered in iTunes Connect. │
│ appstore upload │ Uploads project to iTunes Connect. │
└─────────────────┴──────────────────────────────────────────────────┘
## Device Commands
┌──────────────────────────┬─────────────────────────────────────────────────────────────┐
│ Command │ Description │
│ device │ Lists all recognized connected physical or virtual devices. │
│ device log │ Opens the log stream for the selected device. │
│ device run │ Runs the selected application on a connected device. │
│ device list-applications │ Lists the installed applications on all connected devices. │
└──────────────────────────┴─────────────────────────────────────────────────────────────┘
## Global Options
┌────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Option │ Description │
│ --help, -h, /? │ Prints help about the selected command in the console. │
│ --path │ Specifies the directory that contains the project. If not set, the project is searched for in the current directory and all directories above it. │
│ --version │ Prints the client version. │
│ --log trace │ Prints a detailed diagnostic log for the execution of the current command. │
└────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
root@jimo
公式の例を実行今までandroidの環境を持っていませんでしたが、それを通じて必要なsdkをダウンロードすることができますので、後で言及します.あなたの仕事のカタログにgitを降りてください.
# git clone https://github.com/NativeScript/sample-Groceries.git
'sample-Groceries'...
remote: Counting objects: 5838, done.
: 34% (2031/5838), 16.60 MiB | 54.00 KiB/s
remote: Total 5838 (delta 0), reused 0 (delta 0), pack-reused 5838
: 100% (5838/5838), 56.75 MiB | 918.00 KiB/s, .
delta : 100% (2852/2852), .
そしてプロジェクトディレクトリcheckoutに入ります./sample-Groceries# git checkout start
start origin start。
'start'
現在実行している場合は、プロジェクトの下に環境を追加しなければなりません./sample-Groceries# tns platform add android
Copying template files...
◡ Installing tns-android\
You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=24'.
そして、見つけられませんでした.そして、先にインストールできます.命令ラインでandroidを実行して、それが要求されるandroidバージョンをインストールします.上のバージョンは23から24までです.完了したら再度運転すれば成功します.
/sample-Groceries# tns platform add android
Copying template files...
Project successfully created.
そして、私たちは実機で運転してみます.でも、まず携帯のIDを取得します.次のように命令します.# tns device android
┌───┬─────────────┬──────────┬───────────────────┬────────┬───────────┐
│ # │ Device Name │ Platform │ Device Identifier │ Type │ Status │
│ 1 │ hennessy │ Android │ 5TWWTSOVOFYDMFUC │ Device │ Connected │
└───┴─────────────┴──────────┴───────────────────┴────────┴───────────┘
そして実行:/sample-Groceries# tns run android --device 5TWWTSOVOFYDMFUC
最後にこれは比較的に長い過程になります.もし初めて運行されるなら、彼は帰ってgradle構築ツールなどの一連のファイルをダウンロードして、最後まで見ました.Result is 1910 defs/2248.4KiB. Took 0.4s
:mergeF0DebugJniLibFolders
:transformNative_libsWithMergeJniLibsForF0Debug
:processF0DebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForF0Debug
:validateDebugSigning
:packageF0Debug
:zipalignF0Debug
:assembleF0Debug
:assembleDebug
:buildapk
BUILD SUCCESSFUL
Total time: 34.385 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html
Project successfully built
Successfully deployed on device with identifier '5TWWTSOVOFYDMFUC'.
ですから、このように多くの経験をしました.本物のテストは一番よくないです.次の節にはシミュレータの設置を紹介します.