Easy way to install TensorFlow(tfjs-node) in Windows 11 machine

Rinkesh Patel
2 min readJan 19, 2023

In this article, I am explaining about an easy way to install TensorFlow.js(tfjs-node) on a Windows 11 machine. Why am I writing this when installation instructions are already available on the TensorFlow.js website? I came across a few errors when running ‘npm install’ command. It was not easy to determine what is missing from looking at the error descriptions.

What is tfjs-node?

Fig. 1. Using Node.js addons using require() statements

It is a Node.js addon for TensorFlow which leverages the power of TensorFlow C binary and the hardware acceleration features of your CPU. What is a Node.js addon? Addons are a type of Node.js modules which are written in C/C++ and can be used in node by using require() statements as shown in figure 1.

What are the requirements for compiling and installing tfjs-node?

The requirements are as shown in figure 2 below.

Fig. 2. Requirements for installing tfjs-node

What are the steps to compile and install tfjs-node?

  1. Install python if not available
Fig. 3. Set Path User Variable Step-1
Fig. 4. Set Path User Variable Step-2

2. Edit the path user or system variable; ensure that the path to python is added to the ‘path’ variable.

Fig. 5. Install Visual Studio Community Edition with development environment for C++

3. Install Visual Studio community edition with desktop development with C++

Fig. 6. Visual Studio Community Edition and Build Tools

4. Install visual studio build tools

5. Ensure that node-gyp is available: npm install -g node-gyp

6. Install tfjs-node: npm install @tensorflow/tfjs-node

When building the tfjs-node for your machine. Node-gyp will automatically find these things for you:

  • Visual Studio instance available
  • MSBuild.exe if available
  • Python

In the end, I think sharing this will remove a lot of guess work for other developers looking to work with TensorFlow.js in Windows machines. Thanks for reading.

--

--

Rinkesh Patel

A persistent problem solver trying to dig deeper into day-to-day challenges in Software Engineering and share insights. Love simple and effective solutions.