Introduction
Today I read that nodejs was available on nuget. I wonder why that would be and what extra value that would add to my project. After all nuget is there to install dependent package to my project and keep them up to date. Then I found out that it needed the chocolatey package. The chocolatey package is not really a typical nuget package either. It just uses nuget to get installed. But it peaked my interest. So I installed it.
installing chocolatey
so I went to nuget and opened a solution. Nuget won’t download packages when not in a solution. And then I did the sensible thing and opened the nuget console and entered this command.
install-package chocolatey
With this as the result.
Successfully installed ‘chocolatey 0.9.8.4’.
========================
Chocolatey
========================
Welcome to Chocolatey, your local machine repository for NuGet. Chocolatey allows you to install application packages to your machine with the goodness of a #chocolatey #nuget combo.
Application executables get added to the path automatically so you can call them from anywhere (command line/powershell prompt), not just in Visual Studio.
Lets get Chocolatey!
———-
Visual Studio –
———-
Please run Initialize-Chocolatey one time per machine to set up the repository.
If you are upgrading, please remember to run Initialize-Chocolatey again.
After you have run Initiliaze-Chocolatey, you can safely uninstall the chocolatey package from your current Visual Studio solution.
———-
Alternative NuGet –
———-
If you are not using NuGet in Visual Studio, please navigate to the directory with the chocolateysetup.psm1 and run that in Powershell, followed by Initialize-Chocolatey.
Upgrade is the same, just run Initialize-Chocolatey again.
———-
Once you’ve run initialize or upgrade, you can uninstall this package from the local project without affecting your chocolatey repository.
========================
So I now have chocolatey and I can remove the package from my project.
Next step seems to be to initialize it.
With this as the result.
We are setting up the Chocolatey repository for NuGet packages that should be at the machine level. Think executables/application packages, not library packages.
That is what Chocolatey NuGet goodness is for.
The repository is set up at ‘C:NuGet’.
The packages themselves go to ‘C:NuGetlib’ (i.e. C:NuGetlibyourPackageName).
A batch file for the command line goes to ‘C:NuGetbin’ and points to an executable in ‘C:NuGetlibyourPackageName’.
Creating Chocolatey NuGet folders if they do not already exist.
Mode LastWriteTime Length Name
—- ————- —— —-
d—- 24/07/2011 18:21 bin
d—- 24/07/2011 18:21 lib
d—- 24/07/2011 18:21 chocolateyInstall
Copying the contents of ‘F:mydocumentsvisual studio 2010ProjectsMvcApplication1packageschocolatey.0.9.8.4toolschocolateyInstall’ to ‘C:NuGet’.
Creating ‘C:NuGetbinchocolatey.bat’ so you can call ‘chocolatey’ from anywhere.
Creating ‘C:NuGetbincinst.bat’ so you can call ‘chocolatey install’ from a shortcut of ‘cinst’.
Creating ‘C:NuGetbincinstm.bat’ so you can call ‘chocolatey installmissing’ from a shortcut of ‘cinstm’.
Creating ‘C:NuGetbincup.bat’ so you can call ‘chocolatey update’ from a shortcut of ‘cup’.
Creating ‘C:NuGetbinclist.bat’ so you can call ‘chocolatey list’ from a shortcut of ‘clist’.
Creating ‘C:NuGetbincver.bat’ so you can call ‘chocolatey version’ from a shortcut of ‘cver’.
PATH environment variable does not have C:NuGetbin in it. Adding.
You cannot call a method on a null-valued expression.
At F:mydocumentsvisual studio 2010ProjectsMvcApplication1packageschocolatey.0.9.8.4toolschocolateysetup.psm1:139 char:48
+ $hasStatementTerminator= $userPath.EndsWith <<<< ($statementTerminator) + CategoryInfo : InvalidOperation: (EndsWith:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNullChocolatey is now ready.
You can call chocolatey from anywhere, command line or powershell by typing chocolatey.
Run chocolatey /? for a list of functions.
Not sure if the exception is going to e harmful but I guess I should try.
installing nodejs
Now it is time to install nodejs.
So I typed in
chocolatey install nodejs
With this as the result.
=====================================================
Chocolatey (0.9.8.4) is installing nodejs (from https://go.microsoft.com/fwlink/?LinkID=206669) to “C:NuGetlib”
=====================================================
Package License Acceptance Terms
————————-
Please run chocolatey /? for full license acceptance verbage. By installing you accept the license for the package you are installing…
————————-
————————-
NuGet
————————-
Attempting to resolve dependency ‘chocolatey (= 0.9.8.4)’.
Successfully installed ‘chocolatey 0.9.8.4’.
Successfully installed ‘nodejs 0.5.2’.
————————-
————————-
Chocolatey Runner (CHOCOLATEY)
————————-
————————-
Chocolatey Installation (chocolateyinstall.ps1)
————————-
Looking for chocolateyinstall.ps1 in folder C:NuGetlibchocolatey.0.9.8.4
If chocolateyInstall.ps1 is found, it will be run.
————————-
Elevating Permissions and running powershell -NoProfile -ExecutionPolicy unrestricted -Command “& import-module -name C:NuGetchocolateyInsta
llhelperschocolateyInstaller.psm1; . ‘C:NuGetlibchocolatey.0.9.8.4toolschocolateyInstall.ps1′”. This may take awhile, depending on the p
ackage.
————————-
Executable Batch Links
————————-
Looking for executables in folder: C:NuGetlibchocolatey.0.9.8.4
Adding batch files for any executables found to a location on PATH.
In other words, the executable will be available from ANY command line/powershell prompt.
————————-
Adding C:NuGetbinNuGet.bat and pointing to C:NuGetlibchocolatey.0.9.8.4toolschocolateyInstallNuGet.exe
————————-
————————-
————————-
Chocolatey Runner (NODEJS)
————————-
————————-
Chocolatey Installation (chocolateyinstall.ps1)
————————-
Looking for chocolateyinstall.ps1 in folder C:NuGetlibnodejs.0.5.2
If chocolateyInstall.ps1 is found, it will be run.
————————-
Elevating Permissions and running powershell -NoProfile -ExecutionPolicy unrestricted -Command “& import-module -name C:NuGetchocolateyInsta
llhelperschocolateyInstaller.psm1; . ‘C:NuGetlibnodejs.0.5.2toolschocolateyInstall.ps1′”. This may take awhile, depending on the package
.
————————-
Executable Batch Links
————————-
Looking for executables in folder: C:NuGetlibnodejs.0.5.2
Adding batch files for any executables found to a location on PATH.
In other words, the executable will be available from ANY command line/powershell prompt.
————————-
Adding C:NuGetbinnode.bat and pointing to C:NuGetlibnodejs.0.5.2toolsnode.exe
————————-
=====================================================
Chocolatey has finished installing nodejs
=====================================================
And this along the way.
And now I have to test that node is there I guess.
And yes that counts as proof.
And there are other ways to install chocolatey.
Conclusion
Yep it works, now I just have to see how to get the new version of nodejs when it comes out and how chocolatey will cover this.
Edit: @ferventcoder aka Rob reynolds told me there is a wiki that covers all this. you can just type cver nodejs to check if there is a new version and cup to do the update.