Skip to content

Install node.js 4.2.5 - most stable at the moment #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed setup/empty
Empty file.
Binary file removed setup/empty.tar.gz
Binary file not shown.
17 changes: 13 additions & 4 deletions setup/native-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Google Chr
cinst googlechrome

write-host -BackgroundColor Black -ForegroundColor Yellow "Installing node.js"
cinst nodejs.install -version 5.1.0
cinst nodejs.install -version 4.2.5

write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Java Development Kit"
cinst jdk8
Expand All @@ -20,11 +20,14 @@ write-host -BackgroundColor Black -ForegroundColor Yellow "Installing Android SD
cinst android-sdk

# setup android sdk
echo yes | cmd /c $env:localappdata\Android\android-sdk\tools\android update sdk --filter "tools,platform-tools,android-23,build-tools-23.0.2,extra-android-m2repository" --all --no-ui
echo yes | cmd /c "$env:localappdata\Android\android-sdk\tools\android" update sdk --filter "tools,platform-tools,android-23" --all --no-ui
echo yes | cmd /c "$env:localappdata\Android\android-sdk\tools\android" update sdk --filter "build-tools-23.0.1,extra-android-m2repository" --all --no-ui

# setup environment

if (!$env:ANDROID_HOME) { [Environment]::SetEnvironmentVariable("ANDROID_HOME", "$env:localappdata\Android\android-sdk", "User") }
if (!$env:ANDROID_HOME) {
[Environment]::SetEnvironmentVariable("ANDROID_HOME", "$env:localappdata\Android\android-sdk", "User")
}

if (!$env:JAVA_HOME) {
$curVer = (Get-ItemProperty "HKLM:\SOFTWARE\JavaSoft\Java Development Kit").CurrentVersion
Expand All @@ -34,6 +37,12 @@ if (!$env:JAVA_HOME) {

# install NativeScript CLI
write-host -BackgroundColor Black -ForegroundColor Yellow "Installing NativeScript CLI"
npm install -g nativescript

$oldPathUser = [Environment]::GetEnvironmentVariable("PATH", "User")
$pathMachine = [Environment]::GetEnvironmentVariable("PATH", "Machine")
$myPath = [Environment]::GetEnvironmentVariable("PATH")
[Environment]::SetEnvironmentVariable("PATH", "$myPath;$oldPathUser;$pathMachine;$env:ProgramFiles\nodejs")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not tested it, but according to this forum the PATH will not be "set" in the current Shell until you restart:

To set it PERMANENTLY you use SetEnvironmentVariable, but to have it
take effect NOW you need to use the Env: drive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to MSDN the value will not be set until PowerShell is restarted:

Or at least it didn’t show up until we restarted PowerShell. (Or started up a new instance of PowerShell.)

Maybe we have to use full path to npm (from node installation).
source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am modifying the environment of the currently running PowerShell process, and not the User or System ones. So the forum post and the MSDN article are correct, but not applicable to the code. I can use the shorter syntax though, I did not know it.

We cannot use the full path to npm. This was my first approach and it failed - something (npm, dependencies, or our code) executes node without full path and the installation of the CLI fails because it cannot find node.exe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation :)


cmd /c "npm" install -g nativescript

write-host -BackgroundColor Black -ForegroundColor Yellow "This script has modified your environment. You need to log off and log back on for the changes to take effect."