This sample only works with the Windows 10 IoT Core Anniversary Update (Build 14393) release with Visual Studio 2015 and does not currently work with any newer Windows releases or Visual Studio 2017. We are looking into adding Node.js support to UWP in a future release of Windows 10 IoT Core.
Copy node.exe and chakracore.dll to C:\Node.js (ChakraCore) on your Raspberry Pi 2 or 3.
Create MemoryStatus Addon
Build a native addon for the Node.js server that will be deployed in this sample. This step is required because GlobalMemoryStatusEx is used to get the data we need.
On your Windows 10 PC, create the AddOn location in C:\NodeAddon
Go to C:\NodeAddon
Create new file MemoryStatusAddon.cc, copy the content below and save:
Create a file called binding.gyp (in the same folder as MemoryStatusAddon.cc) and put the contents below in it:
Build the AddOn: "[Node.js (ChakraCore) installation path]\node_modules\npm\bin\node-gyp-bin\node-gyp.cmd" rebuild --target_arch=arm (use appropriate –target_arch depending on the device you have).
The default Node.js (ChakraCore) installation path is “c:\Program Files\nodejs (chakracore)”.
Create the Node.js file
Create a new file called server.js and place the contents below to it.
In the first line, we load the Addon we created prevously. We also load the http module and create a server. When a request is made to the server,
the GlobalMemoryStatusEx method in our Addon is called to retrieve the memory status.
For more information on writing addons, go to https://nodejs.org/api/addons.html.
Copy the files to Windows IoT Core device
Open up an explorer window on your PC and enter \\<IP address of your device>\C$ to access files on your device. The credentials (if you have not changed them) are:
username: <IP address or device name, default is minwinpc>\Administrator
Create a folder on the device called C:\MemoryStatusSample. Then copy the files you created below from your PC to this folder:
Connect to the device using PowerShell. Please follow the instructions found on the Powershell page.
Allow Node.exe to communicate through the firewall with the following command:
In PowerShell, run the command & 'C:\Node.js (ChakraCore)\Node.exe' C:\MemoryStatusSample\server.js to start the server.
Open up a browser and enter the address http://<IP address of your device>:1337. The result should look something like the picture below.